Option Explicit On
Option Strict On
Option Infer On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.IO
Imports System.Net.Http
Imports System.Security.Cryptography.X509Certificates
Imports ADSNetLibrary.SIGAPI.Models.CRM.Request
Imports ADSNetLibrary.SIGAPI.Services.CRM
Imports ADSTimbrado
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json.Linq
Partial Class VentasMedicas
Inherits ClsPaginas
#Region "Propiedades"
Private Const NumeroDecimales As Integer = 2
Dim ColumnaDescuento As Integer = 10
Dim ColumnaPredial As Integer = 11
Dim ColumnaIVA As Integer = 12
Dim ColumnaIEPS As Integer = 13
Dim ColumnaRetIVA As Integer = 14
Dim ColumnaRetISR As Integer = 15
Dim ColumnaEditar As Integer = 17
Dim ColumnaEliminar As Integer = 18
'Factura de ventas
Dim DTConceptos As DataTable
Private Property Version As String
Private Property Fecha As String
Private Property SerieXML As String
Private Property FolioXML As String
Private Property SubTotal As Decimal
Private Property Total As Decimal = 0
' Private Property Descuentos As Decimal = 0
Private Property EmisorRFC As String
Private Property ReceptorRFC As String
Private Property TrasladoIVA As Decimal = 0
Private Property RetencionIVA As Decimal = 0
Private Property RetencionISR As Decimal = 0
Private Property TrasladoIEPS As Decimal = 0
Private Property TFDUUID As String = ""
Private Property Moneda As String = ""
Private Property TipoComprobante As String = ""
Private Property OtrosImpuestos As Decimal = 0
Private Property TotalRetenciones As Decimal = 0
Private Property SumaTotalRetenciones As Decimal = 0
Private Property TotalTraslados As Decimal = 0
Private Property SumaTotalTraslados As Decimal = 0
Private Property SubTotalConceptos As Decimal = 0
Private Property Redondeo As Decimal = 0
Private Property NumRow As Integer
Private Property EsSupervisor As Boolean = False
Private Property MandarCorreoSupervisor As Boolean = False
Private ReadOnly Property ExFolioFactura As Boolean
Get
Return CBool(ViewState("ExFolioFactura"))
End Get
End Property
Private Property CveFactura As Integer
Get
Return ViewState("CveFactura").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveFactura") = value
End Set
End Property
Private Property CuentasContablesInvalidas As StringBuilder
Get
Return CType(ViewState("CuentasContablesInvalidas"), StringBuilder)
End Get
Set(value As StringBuilder)
ViewState("CuentasContablesInvalidas") = value
End Set
End Property
'Local
Private Property DtPorcentajeMarcas As DataTable
Get
Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtPorcentajeMarcas") = value
End Set
End Property
Private Property TmpDT As DataTable
Get
Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDT") = value
End Set
End Property
Private Property TmpDTDescNC As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDescNC")), Nothing, CType(ViewState("TmpDTDescNC"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDescNC") = value
End Set
End Property
Private Property TmpDTDescNCBonificacion As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDescNCBonificacion")), Nothing, CType(ViewState("TmpDTDescNCBonificacion"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDescNCBonificacion") = value
End Set
End Property
Private Property TmpDTBonificacion As DataTable
Get
Return If(IsNothing(ViewState("TmpDTBonificacion")), Nothing, CType(ViewState("TmpDTBonificacion"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTBonificacion") = value
End Set
End Property
Private Property TmpDTRNCBonificacionesCliente As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionesCliente")), Nothing, CType(ViewState("TmpDTRNCBonificacionesCliente"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionesCliente") = value
End Set
End Property
Private Property TmpDTRNCBonificacionesSeleccionadas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionesSeleccionadas")), Nothing, CType(ViewState("TmpDTRNCBonificacionesSeleccionadas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionesSeleccionadas") = value
End Set
End Property
Private Property TmpDTRNCDetalle As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCDetalle")), Nothing, CType(ViewState("TmpDTRNCDetalle"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCDetalle") = value
End Set
End Property
Private Property TmpDTRNCDetalleSelecciondas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCDetalleSelecciondas")), Nothing, CType(ViewState("TmpDTRNCDetalleSelecciondas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCDetalleSelecciondas") = value
End Set
End Property
Private Property TmpDTRNCBonificacionDetalle As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalle")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalle"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionDetalle") = value
End Set
End Property
Private Property TmpDTRNCBonificacionDetalleSeleccionadas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionDetalleSeleccionadas") = value
End Set
End Property
Private Property TmpDTError As DataTable
Get
Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTError") = value
End Set
End Property
Private Property TmpDTImpuestos As DataTable
Get
Return If(IsNothing(ViewState("TmpDTImpuestos")), Nothing, CType(ViewState("TmpDTImpuestos"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTImpuestos") = value
End Set
End Property
Private Property TmpDTImpuestosIVAIEPS As DataTable
Get
Return If(IsNothing(ViewState("TmpDTImpuestosIVAIEPS")), Nothing, CType(ViewState("TmpDTImpuestosIVAIEPS"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTImpuestosIVAIEPS") = value
End Set
End Property
Private Property TmpDTDocumentosRelacionados As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDocumentosRelacionados")), Nothing, CType(ViewState("TmpDTDocumentosRelacionados"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDocumentosRelacionados") = value
End Set
End Property
Private Property TmpDTNCVinculadas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTNCVinculadas")), Nothing, CType(ViewState("TmpDTNCVinculadas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTNCVinculadas") = value
End Set
End Property
Private Property TmpDTEnvioDireccion As DataTable
Get
Return If(IsNothing(ViewState("TmpDTEnvioDireccion")), Nothing, CType(ViewState("TmpDTEnvioDireccion"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTEnvioDireccion") = value
End Set
End Property
Private Property TmpDTDireccionCP As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDireccionCP")), Nothing, CType(ViewState("TmpDTDireccionCP"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDireccionCP") = value
End Set
End Property
Private Property IdPoliza As Integer
Get
Return ViewState("IdPoliza").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("IdPoliza") = value
End Set
End Property
Private Property CveAlmacenDevolucion As Integer
Get
Return ViewState("CveAlmacenDevolucion").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAlmacenDevolucion") = value
End Set
End Property
Private Property EraCotizacion As Integer
Get
Return ViewState("EraCotizacion").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("EraCotizacion") = value
End Set
End Property
Private Property FacturaMateriales As Integer
Get
Return ViewState("FacturaMateriales").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("FacturaMateriales") = value
End Set
End Property
Private Property TmpDTDeducciones As DataTable
Get
Return If(IsNothing(ViewState("TmpDTDeducciones")), Nothing, CType(ViewState("TmpDTDeducciones"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTDeducciones") = value
End Set
End Property
Private Property TmpDTComplementos As DataTable
Get
Return If(IsNothing(ViewState("TmpDTComplementos")), Nothing, CType(ViewState("TmpDTComplementos"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTComplementos") = value
End Set
End Property
Private Property DTmpC As DataTable
Get
Return If(IsNothing(ViewState("DTmpC")), Nothing, CType(ViewState("DTmpC"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTmpC") = value
End Set
End Property
Private Property DTmpF As DataTable
Get
Return If(IsNothing(ViewState("DTmpF")), Nothing, CType(ViewState("DTmpF"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTmpF") = value
End Set
End Property
Private Property DTSucursal As DataTable
Get
Return If(IsNothing(ViewState("DTSucursal")), Nothing, CType(ViewState("DTSucursal"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTSucursal") = value
End Set
End Property
Private Property DTOrdenesCompra As DataTable
Get
Return If(IsNothing(ViewState("DTOrdenesCompra")), Nothing, CType(ViewState("DTOrdenesCompra"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTOrdenesCompra") = value
End Set
End Property
Private Property DTOrdenesCompraPS As DataTable
Get
Return If(IsNothing(ViewState("DTOrdenesCompraPS")), Nothing, CType(ViewState("DTOrdenesCompraPS"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTOrdenesCompraPS") = value
End Set
End Property
Private Property DtOCTmpDT As DataTable
Get
Return If(IsNothing(ViewState("DtOCTmpDT")), Nothing, CType(ViewState("DtOCTmpDT"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtOCTmpDT") = value
End Set
End Property
Private Property DTRemisiones As DataTable
Get
Return If(IsNothing(ViewState("DTRemisiones")), Nothing, CType(ViewState("DTRemisiones"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTRemisiones") = value
End Set
End Property
Private Property ListaDescuentos As List(Of Modelos.VentaDescuentos)
Get
Return If(IsNothing(ViewState("ListaDescuentos")), Nothing, CType(ViewState("ListaDescuentos"), List(Of Modelos.VentaDescuentos)))
End Get
Set(value As List(Of Modelos.VentaDescuentos))
ViewState("ListaDescuentos") = value
End Set
End Property
Private Property RemisionesLista As List(Of Integer)
Get
Return If(IsNothing(ViewState("RemisionesLista")), Nothing, CType(ViewState("RemisionesLista"), List(Of Integer)))
End Get
Set(value As List(Of Integer))
ViewState("RemisionesLista") = value
End Set
End Property
Private Property ListaRemisionesNC As List(Of Modelos.Factura)
Get
Return If(IsNothing(ViewState("ListaRemisionesNC")), Nothing, CType(ViewState("ListaRemisionesNC"), List(Of Modelos.Factura)))
End Get
Set(value As List(Of Modelos.Factura))
ViewState("ListaRemisionesNC") = value
End Set
End Property
Private Property ListaNCDesc As List(Of Modelos.Factura)
Get
Return If(IsNothing(ViewState("ListaNCDesc")), Nothing, CType(ViewState("ListaNCDesc"), List(Of Modelos.Factura)))
End Get
Set(value As List(Of Modelos.Factura))
ViewState("ListaNCDesc") = value
End Set
End Property
Private Property ListaNCBonificacion As List(Of Modelos.Factura)
Get
Return If(IsNothing(ViewState("ListaNCBonificacion")), Nothing, CType(ViewState("ListaNCBonificacion"), List(Of Modelos.Factura)))
End Get
Set(value As List(Of Modelos.Factura))
ViewState("ListaNCBonificacion") = value
End Set
End Property
Private Property Pedidos2Lista As List(Of Integer)
Get
Return If(IsNothing(ViewState("Pedidos2Lista")), Nothing, CType(ViewState("Pedidos2Lista"), List(Of Integer)))
End Get
Set(value As List(Of Integer))
ViewState("Pedidos2Lista") = value
End Set
End Property
Private Property DtRemisionesPS As DataTable
Get
Return If(IsNothing(ViewState("DtRemisionesPS")), Nothing, CType(ViewState("DtRemisionesPS"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtRemisionesPS") = value
End Set
End Property
Private Property DtCotizaciones As DataTable
Get
Return If(IsNothing(ViewState("DtCotizaciones")), Nothing, CType(ViewState("DtCotizaciones"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtCotizaciones") = value
End Set
End Property
Private Property CotizacionesLista As List(Of Integer)
Get
Return If(IsNothing(ViewState("CotizacionesLista")), Nothing, CType(ViewState("CotizacionesLista"), List(Of Integer)))
End Get
Set(value As List(Of Integer))
ViewState("CotizacionesLista") = value
End Set
End Property
Private Property DtCotizacionesPS As DataTable
Get
Return If(IsNothing(ViewState("DtCotizacionesPS")), Nothing, CType(ViewState("DtCotizacionesPS"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtCotizacionesPS") = value
End Set
End Property
Private Property DtCotizacionTmpDT As DataTable
Get
Return If(IsNothing(ViewState("DtCotizacionTmpDT")), Nothing, CType(ViewState("DtCotizacionTmpDT"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtCotizacionTmpDT") = value
End Set
End Property
Private Property DtRemisionesTmpDT As DataTable
Get
Return If(IsNothing(ViewState("DtRemisionesTmpDT")), Nothing, CType(ViewState("DtRemisionesTmpDT"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtRemisionesTmpDT") = value
End Set
End Property
Private Property DtPedidos2TmpDT As DataTable
Get
Return If(IsNothing(ViewState("DtPedidos2TmpDT")), Nothing, CType(ViewState("DtPedidos2TmpDT"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtPedidos2TmpDT") = value
End Set
End Property
Private Property DtRemConceptosSurtidos As DataTable
Get
Return If(IsNothing(ViewState("DtRemConceptosSurtidos")), Nothing, CType(ViewState("DtRemConceptosSurtidos"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtRemConceptosSurtidos") = value
End Set
End Property
Private Property HuboCambioRemi As Boolean
Get
Return If(IsNothing(ViewState("HuboCambioRemi")), False, CType(ViewState("HuboCambioRemi"), Boolean))
End Get
Set(value As Boolean)
ViewState("HuboCambioRemi") = value
End Set
End Property
Private Property AplicaGastoContrato As Boolean
Get
Return If(IsNothing(ViewState("AplicaGastoContrato")), False, CType(ViewState("AplicaGastoContrato"), Boolean))
End Get
Set(value As Boolean)
ViewState("AplicaGastoContrato") = value
End Set
End Property
Private Property EsCreaApartirDe As Boolean
Get
Return If(IsNothing(ViewState("EsCreaApartirDe")), False, CType(ViewState("EsCreaApartirDe"), Boolean))
End Get
Set(value As Boolean)
ViewState("EsCreaApartirDe") = value
End Set
End Property
Private Property RequiereAlmacenDestino As Boolean
Get
Return If(IsNothing(ViewState("RequiereAlmacenDestino")), False, CType(ViewState("RequiereAlmacenDestino"), Boolean))
End Get
Set(value As Boolean)
ViewState("RequiereAlmacenDestino") = value
End Set
End Property
Private Property RequiereAlmacenOrigen As Boolean
Get
Return If(IsNothing(ViewState("RequiereAlmacenOrigen")), False, CType(ViewState("RequiereAlmacenOrigen"), Boolean))
End Get
Set(value As Boolean)
ViewState("RequiereAlmacenOrigen") = value
End Set
End Property
Private Property AplicoNCFacturaActual As Boolean
Get
Return If(IsNothing(ViewState("AplicoNCFacturaActual")), False, CType(ViewState("AplicoNCFacturaActual"), Boolean))
End Get
Set(value As Boolean)
ViewState("AplicoNCFacturaActual") = value
End Set
End Property
Private Property EmpresaActual As Empresa
Get
Return CType(ViewState("EmpresaActual"), Empresa)
End Get
Set(value As Empresa)
ViewState("EmpresaActual") = value
End Set
End Property
Property CargaDocumentoOC As Boolean
Get
If ViewState("CargaDocumentoOC") Is Nothing Then
Return False
Else
Return DirectCast(ViewState("CargaDocumentoOC"), Boolean)
End If
End Get
Set(value As Boolean)
ViewState("CargaDocumentoOC") = value
End Set
End Property
Private Property DTFacNC As DataTable
Get
Return If(IsNothing(ViewState("DTFacNC")), Nothing, CType(ViewState("DTFacNC"), DataTable))
End Get
Set(value As DataTable)
ViewState("DTFacNC") = value
End Set
End Property
Private Property DtPromociones As DataTable
Get
Return If(IsNothing(ViewState("DtPromociones")), Nothing, CType(ViewState("DtPromociones"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtPromociones") = value
End Set
End Property
Private ReadOnly Property CveCliente As Integer
Get
Return ViewState("CveCliente").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property CveClienteAnterior As Integer
Get
Return ViewState("CveClienteAnterior").ToString().ToEntero()
End Get
End Property
Private Property CveClienteSucursal As Integer
Get
If ViewState("CveClienteSucursal") Is Nothing Then
Return -1
Else
Return ViewState("CveClienteSucursal").ToString().ToEntero()
End If
End Get
Set(value As Integer)
ViewState("CveClienteSucursal") = value
End Set
End Property
Private Property CveAnticipo As Integer
Get
If ViewState("CveAnticipo") Is Nothing Then
Return -1
Else
Return ViewState("CveAnticipo").ToString().ToEntero()
End If
End Get
Set(value As Integer)
ViewState("CveAnticipo") = value
End Set
End Property
Private Property CveUsuarioActual As Integer
Get
Return ViewState("CveUsuarioActual").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveUsuarioActual") = value
End Set
End Property
Private ReadOnly Property Mail As String
Get
Return IfNull(ViewState("Mail"), "").ToString()
End Get
End Property
Private ReadOnly Property MailCC As String
Get
Return IfNull(ViewState("MailCC"), "").ToString()
End Get
End Property
Public ReadOnly Property CveVenta As Integer
Get
Return ViewState("CveVenta").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property CveSubProyectoVenta As Integer
Get
Return If(IsNothing(ViewState("CveSubProyectoVenta")), -1, ViewState("CveSubProyectoVenta").ToString().ToEntero())
End Get
End Property
Private Property CveVentaPadre As Integer
Get
Return If(IsNothing(ViewState("CveVentaPadre")), -1, ViewState("CveVentaPadre").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveVentaPadre") = value
End Set
End Property
Private Property CveEstatusFacturaPadre As Integer
Get
Return If(IsNothing(ViewState("CveEstatusFacturaPadre")), -1, ViewState("CveEstatusFacturaPadre").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveEstatusFacturaPadre") = value
End Set
End Property
Private Property CveMovimientoDetalle As Integer
Get
Return If(IsNothing(ViewState("CveMovimientoDetalle")), -1, ViewState("CveMovimientoDetalle").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveMovimientoDetalle") = value
End Set
End Property
Private ReadOnly Property CveDevolucion As Integer
Get
Return ViewState("CveDevolucion").ToString().ToEntero()
End Get
End Property
Private Property CveVentaRelacion As Integer
Get
Return If(IsNothing(ViewState("CveVentaRelacion")), -1, ViewState("CveVentaRelacion").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveVentaRelacion") = value
End Set
End Property
Private Property ImporteRelacion As Double
Get
Return If(IsNothing(ViewState("ImporteRelacion")), 0, ViewState("ImporteRelacion").ToString().ToDouble)
End Get
Set(value As Double)
ViewState("ImporteRelacion") = value
End Set
End Property
Private Property IsTotalxConcepto As Boolean
Get
Return If(IsNothing(ViewState("IsTotalxConcepto")), False, CBool(ViewState("IsTotalxConcepto").ToString()))
End Get
Set(value As Boolean)
ViewState("IsTotalxConcepto") = value
End Set
End Property
Private ReadOnly Property CveAlmacenTransitorio As Integer
Get
Return ViewState("CveAlmacenTransitorio").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property NuevaFactura As Integer
Get
Return ViewState("NuevaFactura").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property VentaFolio As String
Get
Return ViewState("VentaFolio").ToString()
End Get
End Property
Private ReadOnly Property SelloCancelacion As String
Get
Return ViewState("SelloCancelacion").ToString()
End Get
End Property
Private ReadOnly Property FechaCancelacion As DateTime
Get
Return ViewState("FechaCancelacion").ToString().ToDateTime
End Get
End Property
Private ReadOnly Property EstablecioFolio As Boolean
Get
Return CBool(ViewState("EstablecioFolio"))
End Get
End Property
Private ReadOnly Property FolioFiscal As String
Get
Return ViewState("FolioFiscal").ToString()
End Get
End Property
Private ReadOnly Property Ruta As String
Get
Return UsuarioActual.Empresa.Ruta
End Get
End Property
Private ReadOnly Property RutaPruebas As String
Get
Return String.Format("{0}Empresas/1/", ModExtensiones.DirectorioBaseEmpresas)
End Get
End Property
Private ReadOnly Property TipoCambio As Decimal
Get
Return ViewState("TipoCambio").ToString().ToDecimal
End Get
End Property
Private ReadOnly Property ProcesoCorrecto As Boolean
Get
Return CBool(ViewState("ProcesoCorrecto"))
End Get
End Property
'FUENTES RECAUDACIÓN
Private Property DTPresupuestoIngresos As DataTable
Get
Return CType(ViewState("DTPresupuestoIngresos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTPresupuestoIngresos") = value
End Set
End Property
'Folios
Private ReadOnly Property CveFolio As Integer
Get
Return ViewState("CveFolio").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property NumAprobacion As Long
Get
Return CLng(ViewState("NumAprobacion").ToString())
End Get
End Property
Private ReadOnly Property FechaAprobacion As Date
Get
Return ViewState("FechaAprobacion").ToString().ToDate
End Get
End Property
Private ReadOnly Property FolioActual As String
Get
Return ViewState("FolioActual").ToString()
End Get
End Property
'Sucursal
Private ReadOnly Property Serie As String
Get
Return ViewState("Serie").ToString()
End Get
End Property
Private ReadOnly Property Folio As Integer
Get
Return ViewState("Folio").ToString().ToEntero()
End Get
End Property
Private ReadOnly Property FormatoFactura As String
Get
Return ViewState("FormatoFactura").ToString()
End Get
End Property
Private ReadOnly Property TipoFormato As String
Get
Return ViewState("TipoFormato").ToString()
End Get
End Property
Private ReadOnly Property IVA As Decimal
Get
Return ViewState("IVA").ToString().ToDecimal
End Get
End Property
'Private ReadOnly Property SubProyectoPorcentajeIVA As Decimal
' Get
' Return ViewState("SubProyectoPorcentajeIVA").ToString().ToDecimal
' End Get
'End Property
Private ReadOnly Property ClienteRetIVA As Decimal
Get
Return ViewState("ClienteRetIVA").ToString().ToDecimal
End Get
End Property
Private ReadOnly Property ClienteRetISR As Decimal
Get
Return ViewState("ClienteRetISR").ToString().ToDecimal
End Get
End Property
Private ReadOnly Property ClienteDesglosaIEPS As Boolean
Get
Return CType(ViewState("ClienteDesglosaIEPS").ToString(), Boolean)
End Get
End Property
Private ReadOnly Property ClienteNODesglosaIVA As Boolean
Get
Return CType(ViewState("ClienteNODesglosaIVA").ToString(), Boolean)
End Get
End Property
'Cliente
Private ReadOnly Property NombreCliente As String
Get
Return ViewState("NombreCliente").ToString()
End Get
End Property
Private ReadOnly Property Vendedor As String
Get
Return ViewState("Vendedor").ToString()
End Get
End Property
Private ReadOnly Property CodCliente As String
Get
Return ViewState("CodCliente").ToString()
End Get
End Property
Private ReadOnly Property CliNoExt As String
Get
Return ViewState("CliNoExt").ToString()
End Get
End Property
Private ReadOnly Property CliNoInt As String
Get
Return ViewState("CliNoInt").ToString()
End Get
End Property
Private ReadOnly Property CliLocalidad As String
Get
Return ViewState("CliLocalidad").ToString()
End Get
End Property
Private ReadOnly Property CliPais As String
Get
Return ViewState("CliPais").ToString()
End Get
End Property
Private ReadOnly Property SucCalle As String
Get
Return ViewState("SucCalle").ToString()
End Get
End Property
Private ReadOnly Property CliCorreoCot As String
Get
If ViewState("CliCorreoCot") Is Nothing Then
Return ""
Else
Return ViewState("CliCorreoCot").ToString()
End If
End Get
End Property
Private ReadOnly Property SucNoExt As String
Get
Return ViewState("SucNoExt").ToString()
End Get
End Property
Private ReadOnly Property SucNoInt As String
Get
Return ViewState("SucNoInt").ToString()
End Get
End Property
Private ReadOnly Property SucColonia As String
Get
Return ViewState("SucColonia").ToString()
End Get
End Property
Private ReadOnly Property SucLocalidad As String
Get
Return ViewState("SucLocalidad").ToString()
End Get
End Property
Private ReadOnly Property SucMunicipio As String
Get
Return ViewState("SucMunicipio").ToString()
End Get
End Property
Private ReadOnly Property SucEstado As String
Get
Return ViewState("SucEstado").ToString()
End Get
End Property
Private ReadOnly Property SucPais As String
Get
Return ViewState("SucPais").ToString()
End Get
End Property
Private ReadOnly Property SucCP As String
Get
Return ViewState("SucCP").ToString()
End Get
End Property
Private ReadOnly Property MatCalle As String
Get
Return ViewState("MatCalle").ToString()
End Get
End Property
Private ReadOnly Property MatNoExt As String
Get
Return ViewState("MatNoExt").ToString()
End Get
End Property
Private ReadOnly Property MatNoInt As String
Get
Return ViewState("MatNoInt").ToString()
End Get
End Property
Private ReadOnly Property MatColonia As String
Get
Return ViewState("MatColonia").ToString()
End Get
End Property
Private ReadOnly Property MatLocalidad As String
Get
Return ViewState("MatLocalidad").ToString()
End Get
End Property
Private ReadOnly Property MatMunicipio As String
Get
Return ViewState("MatMunicipio").ToString()
End Get
End Property
Private ReadOnly Property MatEstado As String
Get
Return ViewState("MatEstado").ToString()
End Get
End Property
Private ReadOnly Property MatPais As String
Get
Return ViewState("MatPais").ToString()
End Get
End Property
Private ReadOnly Property MatCP As String
Get
Return ViewState("MatCP").ToString()
End Get
End Property
Private Property ImprimeNombreSucursal As Boolean
Get
Return CBool(ViewState("ImprimeNombreSucursal"))
End Get
Set(value As Boolean)
ViewState("ImprimeNombreSucursal") = value
End Set
End Property
Private ReadOnly Property AplicaFEMSA As Boolean
Get
Return CBool(ViewState("AplicaFEMSA"))
End Get
End Property
Private ReadOnly Property AplicaComercioExterior As Boolean
Get
Return CBool(ViewState("AplicaComercioExterior"))
End Get
End Property
Private ReadOnly Property CveTipoOperacion As Integer
Get
Return CInt(ViewState("CveTipoOperacion"))
End Get
End Property
Private ReadOnly Property CvePedimento As Integer
Get
Return CInt(ViewState("CvePedimento"))
End Get
End Property
Private ReadOnly Property CveIncoterm As Integer
Get
Return CInt(ViewState("CveIncoterm"))
End Get
End Property
Private ReadOnly Property AplicaDetallista As Boolean
Get
Return CBool(ViewState("AplicaDetallista"))
End Get
End Property
Private ReadOnly Property AplicaFord As Boolean
Get
Return CBool(ViewState("AplicaFord"))
End Get
End Property
Private Property CveOS As Integer
Get
Return ViewState("CveOS").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveOS") = value
End Set
End Property
Private ReadOnly Property SaldoVenta As Decimal
Get
Return If(IsNothing(ViewState("SaldoVenta")), 0, ViewState("SaldoVenta").ToString().ToDecimal)
End Get
End Property
Private Property CvePSAmortizacion As Integer
Get
Return ViewState("CvePSAmortizacion").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePSAmortizacion") = value
End Set
End Property
'Inventarios
Private Property DtInv As DataTable
Get
Return CType(ViewState("DtInv"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtInv") = value
End Set
End Property
Private Property CvePrePoliza As Integer
Get
Return ViewState("CvePrePoliza").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePrePoliza") = value
End Set
End Property
Private ReadOnly Property SeGuardoPrePoliza As Boolean
Get
Return CBool(ViewState("SeGuardoPrePoliza"))
End Get
End Property
Private Property CveVentaFacturada As Integer
Get
Return ViewState("CveVentaFacturada").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveVentaFacturada") = value
End Set
End Property
Private ReadOnly Property AplicarVentaFacturada As Boolean
Get
Return CBool(ViewState("AplicarVentaFacturada"))
End Get
End Property
'Estimaciones
Private Property CveContrato As Integer
Get
Return ViewState("CveContrato").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveContrato") = value
End Set
End Property
Private Property CvePedido As Integer
Get
Return ViewState("CvePedido").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePedido") = value
End Set
End Property
Private Property CvePedido2 As Integer
Get
Return ViewState("CvePedido2").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePedido2") = value
End Set
End Property
Private Property TipoContrato As Integer
Get
Return ViewState("TipoContrato").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("TipoContrato") = value
End Set
End Property
Private Property Opcion As String
Get
Return ViewState("Opcion").ToString()
End Get
Set(value As String)
ViewState("Opcion") = value
End Set
End Property
Private Property CorreoNotificacionPedDev As String
Get
Return If(IsNothing(ViewState("CorreoNotificacionDevPed")), "", ViewState("CorreoNotificacionDevPed").ToString())
End Get
Set(value As String)
ViewState("CorreoNotificacionDevPed") = value
End Set
End Property
'Presupuesto
Private Property CvePresupuesto As Integer
Get
Return ViewState("CvePresupuesto").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePresupuesto") = value
End Set
End Property
Private Property TotalOtrosConceptos As Decimal
Get
Return ViewState("TotalOtrosConceptos").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("TotalOtrosConceptos") = value
End Set
End Property
Private Property TipoCambioFactura As Decimal
Get
Return ViewState("TipoCambioFactura").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("TipoCambioFactura") = value
End Set
End Property
Private Property DtPagos As DataTable
Get
Return CType(ViewState("DtPagos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPagos") = value
End Set
End Property
Private Property DevolucionAlmacen As Integer
Get
Return ViewState("DevolucionAlmacen").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("DevolucionAlmacen") = value
End Set
End Property
Private Property DevolucionAlmacenNC As Integer
Get
Return IfNull(ViewState("DevolucionAlmacenNC"), 2, ViewState("DevolucionAlmacenNC").ToString().ToString()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("DevolucionAlmacenNC") = value
End Set
End Property
Private ReadOnly Property TipoDoctoDevolucion As String
Get
Return ViewState("TipoDoctoDevolucion").ToString()
End Get
End Property
Private Property PlazoCobranza As Integer
Get
Return ViewState("PlazoCobranza").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("PlazoCobranza") = value
End Set
End Property
Private Property PlazoCobranzaRemision As Integer
Get
Return ViewState("PlazoCobranzaRemision").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("PlazoCobranzaRemision") = value
End Set
End Property
'CvePAC
Private Property CvePAC As Integer
Get
Return ViewState("CvePAC").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePAC") = value
End Set
End Property
Private Property AplicaDevolucion As Boolean
Get
Return If(IsNothing(ViewState("AplicaDevolucion")), False, CType(ViewState("AplicaDevolucion"), Boolean))
End Get
Set(value As Boolean)
ViewState("AplicaDevolucion") = value
End Set
End Property
Private Property CveVentaDevolucion As Integer
Get
Return If(IsNothing(ViewState("CveVentaDevolucion")), 0, CType(ViewState("CveVentaDevolucion"), Integer))
End Get
Set(value As Integer)
ViewState("CveVentaDevolucion") = value
End Set
End Property
Private Property SaldoVentaDevolucion As Decimal
Get
Return ViewState("SaldoVentaDevolucion").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("SaldoVentaDevolucion") = value
End Set
End Property
Private Property ContratoOC As Boolean
Get
Return If(IsNothing(ViewState("ContratoOC")), False, CType(ViewState("ContratoOC"), Boolean))
End Get
Set(value As Boolean)
ViewState("ContratoOC") = value
End Set
End Property
Private Property TieneAlmacen As Boolean
Get
Return If(IsNothing(ViewState("TieneAlmacen")), False, CType(ViewState("TieneAlmacen"), Boolean))
End Get
Set(value As Boolean)
ViewState("TieneAlmacen") = value
End Set
End Property
Private Property PorcentajeIVA As Decimal
Get
Return ViewState("PorcentajeIVA").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("PorcentajeIVA") = value
End Set
End Property
Private Property CveEstatusRefacturacion As Integer
Get
Return If(IsNothing(ViewState("CveEstatusRefacturacion")), 0, CType(ViewState("CveEstatusRefacturacion"), Integer))
End Get
Set(value As Integer)
ViewState("CveEstatusRefacturacion") = value
End Set
End Property
Private Property RefacturarCancelada As Boolean
Get
Return If(IsNothing(ViewState("RefacturarCancelada")), False, CBool(ViewState("RefacturarCancelada")))
End Get
Set(value As Boolean)
ViewState("RefacturarCancelada") = value
End Set
End Property
Private Property CveEstadoCancelacion As Integer
Get
Return If(IsNothing(ViewState("CveEstadoCancelacion")), 0, CType(ViewState("CveEstadoCancelacion"), Integer))
End Get
Set(value As Integer)
ViewState("CveEstadoCancelacion") = value
End Set
End Property
Private Property PermiteCredito As Boolean
Get
Return If(IsNothing(ViewState("PermiteCredito")), False, CBool(ViewState("PermiteCredito")))
End Get
Set(value As Boolean)
ViewState("PermiteCredito") = value
End Set
End Property
Private Property DtAnticipoAmortizacion As DataTable
Get
Return CType(ViewState("DtAnticipoAmortizacion"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAnticipoAmortizacion") = value
End Set
End Property
Private Property SaldoAnticipo As Decimal
Get
Return If(IsNothing(ViewState("SaldoAnticipo")), 0, ViewState("SaldoAnticipo").ToString().ToDecimal())
End Get
Set(value As Decimal)
ViewState("SaldoAnticipo") = value
End Set
End Property
Private Property CorreoEntregaAlmacen As String
Get
Return If(IsNothing(ViewState("CorreoEntregaAlmacen")), "", ViewState("CorreoEntregaAlmacen").ToString())
End Get
Set(value As String)
ViewState("CorreoEntregaAlmacen") = value
End Set
End Property
Private Property CveVentaUsadoDevolucionEfectivo As Integer
Get
Return If(IsNothing(ViewState("CveVentaUsadoDevolucionEfectivo")), 0, CType(ViewState("CveVentaUsadoDevolucionEfectivo"), Integer))
End Get
Set(value As Integer)
ViewState("CveVentaUsadoDevolucionEfectivo") = value
End Set
End Property
Private Property RFCReceptorVenta As String
Get
Return If(IsNothing(ViewState("RFCReceptorVenta")), "", ViewState("RFCReceptorVenta").ToString())
End Get
Set(value As String)
ViewState("RFCReceptorVenta") = value
End Set
End Property
Private Property RegimenFiscalCliente As String
Get
Return IfNull(ViewState("RegimenFiscalCliente"), "").ToString()
End Get
Set(value As String)
ViewState("RegimenFiscalCliente") = value
End Set
End Property
Private Property RegimenSociedad As String
Get
Return IfNull(ViewState("RegimenSociedad"), "").ToString()
End Get
Set(value As String)
ViewState("RegimenSociedad") = value
End Set
End Property
Private Property TipoPersona As Boolean
Get
Return CBool(IfNull(ViewState("TipoPersona"), False))
End Get
Set(value As Boolean)
ViewState("TipoPersona") = value
End Set
End Property
Private Property Adjunto As String
Get
Return If(IsNothing(ViewState("Adjunto")), "", ViewState("Adjunto").ToString())
End Get
Set(value As String)
ViewState("Adjunto") = value
End Set
End Property
Private Property VentaActual As Venta
Get
Return DirectCast(ViewState("VentaActual"), Venta)
End Get
Set(value As Venta)
ViewState("VentaActual") = value
End Set
End Property
Private Property ListaAnticiposAplicados As List(Of Modelos.MAnticipoRelacionado)
Get
Return If(IsNothing(ViewState("ListaAnticiposAplicados")), Nothing, CType(ViewState("ListaAnticiposAplicados"), List(Of Modelos.MAnticipoRelacionado)))
End Get
Set(value As List(Of Modelos.MAnticipoRelacionado))
ViewState("ListaAnticiposAplicados") = value
End Set
End Property
Private Property CveTimbreCartaPorteVenta As Integer
Get
Return If(IsNothing(ViewState("CveTimbreCartaPorteVenta")), -1, ViewState("CveTimbreCartaPorteVenta").ToString().ToEntero())
End Get
Set(value As Integer)
ViewState("CveTimbreCartaPorteVenta") = value
End Set
End Property
#End Region
#Region "Propiedades PuntoVenta"
Private Property CveCorte As Integer
Get
Return ViewState("CveCorte").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveCorte") = value
End Set
End Property
Private Property Entrega As String
Get
Return ViewState("Entrega").ToString()
End Get
Set(value As String)
ViewState("Entrega") = value
End Set
End Property
Private Property Vigencia As String
Get
Return ViewState("Vigencia").ToString()
End Get
Set(value As String)
ViewState("Vigencia") = value
End Set
End Property
Private Property DineroCaja As Double
Get
Return ViewState("DineroCaja").ToString().ToDouble
End Get
Set(value As Double)
ViewState("DineroCaja") = value
End Set
End Property
Private ReadOnly Property CveCicloComercial As Integer
Get
Return ViewState("CveCicloComercial").ToString().ToEntero()
End Get
End Property
#End Region
#Region "Propiedades Contratos"
Private Property DtContratos As DataTable
Get
Return If(IsNothing(ViewState("DtContratos")), Nothing, CType(ViewState("DtContratos"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtContratos") = value
End Set
End Property
Private Property NumeroContrato As String
Get
Return ViewState("NumeroContrato").ToString()
End Get
Set(value As String)
ViewState("NumeroContrato") = value
End Set
End Property
Private Property DescripcionContrato As String
Get
Return ViewState("DescripcionContrato").ToString()
End Get
Set(value As String)
ViewState("DescripcionContrato") = value
End Set
End Property
Private Property NumeroLicitacion As String
Get
Return ViewState("NumeroLicitacion").ToString()
End Get
Set(value As String)
ViewState("NumeroLicitacion") = value
End Set
End Property
Private Property CveAlmacenExistenciasContrato As Integer
Get
Return ViewState("CveAlmacenExistenciasContrato").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAlmacenExistenciasContrato") = value
End Set
End Property
Private Property CveAlmacenOrigenContrato As Integer
Get
Return ViewState("CveAlmacenOrigenContrato").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAlmacenOrigenContrato") = value
End Set
End Property
Private Property DtContratosSerieDetalle As DataTable
Get
Return If(IsNothing(ViewState("DtContratosSerieDetalle")), Nothing, CType(ViewState("DtContratosSerieDetalle"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtContratosSerieDetalle") = value
End Set
End Property
Private Property CvePSSerie As Integer
Get
Return CType(ViewState("CvePSSerie"), Integer)
End Get
Set(value As Integer)
ViewState("CvePSSerie") = value
End Set
End Property
Private Property CveUMSerie As Integer
Get
Return CType(ViewState("CveUMSerie"), Integer)
End Get
Set(value As Integer)
ViewState("CveUMSerie") = value
End Set
End Property
Private Property CveConsecSerie As Integer
Get
Return CType(ViewState("CveConsecSerie"), Integer)
End Get
Set(value As Integer)
ViewState("CveConsecSerie") = value
End Set
End Property
Private Property LimitaCantidadSerie As Integer
Get
Return CType(ViewState("LimitaCantidadSerie"), Integer)
End Get
Set(value As Integer)
ViewState("LimitaCantidadSerie") = value
End Set
End Property
Private Property PorAmortizacionAnticipo As Integer
Get
If ViewState("PorAmortizacionAnticipo") Is Nothing Then
Return 0
Else
Return CType(ViewState("PorAmortizacionAnticipo"), Integer)
End If
End Get
Set(value As Integer)
ViewState("PorAmortizacionAnticipo") = value
End Set
End Property
Private Property AmortizacionSujeridaContrato As Decimal
Get
If ViewState("AmortizacionSujeridaContrato") Is Nothing Then
Return 0
Else
Return ViewState("AmortizacionSujeridaContrato").ToString.ToDecimal
End If
End Get
Set(value As Decimal)
ViewState("AmortizacionSujeridaContrato") = value
End Set
End Property
Private Property EscontratoObra As Boolean
Get
If ViewState("EscontratoObra") Is Nothing Then
Return False
Else
Return Boolean.Parse(ViewState("EscontratoObra").ToString)
End If
End Get
Set(value As Boolean)
ViewState("EscontratoObra") = value
End Set
End Property
#End Region
#Region " PROPIEDADES NUEVAS | GUARDAR - IMPRESION "
Private Property ErrorList As List(Of String)
Get
Return CType(ViewState("ErrorList"), List(Of String))
End Get
Set(value As List(Of String))
ViewState("ErrorList") = value
End Set
End Property
Private Property MensajeAlert As StringBuilder
Get
Return CType(ViewState("MensajeAlert"), StringBuilder)
End Get
Set(value As StringBuilder)
ViewState("MensajeAlert") = value
End Set
End Property
Private Property ObjFactura As Modelos.Factura
Get
Return CType(ViewState("ObjFactura"), Modelos.Factura)
End Get
Set(value As Modelos.Factura)
ViewState("ObjFactura") = value
End Set
End Property
Private Property ObjFacturaDevolucion As Modelos.Factura
Get
Return CType(ViewState("ObjFacturaDevolucion"), Modelos.Factura)
End Get
Set(value As Modelos.Factura)
ViewState("ObjFacturaDevolucion") = value
End Set
End Property
Private Property ObjFacturaBonificacion As Modelos.Factura
Get
Return CType(ViewState("ObjFacturaBonificacion"), Modelos.Factura)
End Get
Set(value As Modelos.Factura)
ViewState("ObjFacturaBonificacion") = value
End Set
End Property
Private Property ObjFacturaNC As Modelos.Factura
Get
Return CType(ViewState("ObjFacturaNC"), Modelos.Factura)
End Get
Set(value As Modelos.Factura)
ViewState("ObjFacturaNC") = value
End Set
End Property
#End Region
#Region " PROPIEDADES NUEVAS "
Private Property CveOC As Integer
Get
Return ViewState("CveOC").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveOC") = value
End Set
End Property
Private Property RegistroxOC As Boolean
Get
Return CBool(IfNull(ViewState("RegistroxOC"), False))
End Get
Set(value As Boolean)
ViewState("RegistroxOC") = value
End Set
End Property
Private Property EnviarCorreoCliente As Boolean
Get
Return CBool(IfNull(ViewState("EnviarCorreoCliente"), False))
End Get
Set(value As Boolean)
ViewState("EnviarCorreoCliente") = value
End Set
End Property
Private Property EstatusCliente As Boolean
Get
Return CBool(ViewState("EstatusCliente").ToString())
End Get
Set(value As Boolean)
ViewState("EstatusCliente") = value
End Set
End Property
'Private Property CveMetodoPagoCliente As Integer
' Get
' Return ViewState("CveMetodoPagoCliente").ToString().ToEntero()
' End Get
' Set(value As Integer)
' ViewState("CveMetodoPagoCliente") = value
' End Set
'End Property
Private Property Modalidad As String
Get
Return ViewState("Modalidad").ToString()
End Get
Set(value As String)
ViewState("Modalidad") = value
End Set
End Property
Private Property Index As Integer
Get
Return ViewState("Index").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("Index") = value
End Set
End Property
Private Property TotAnt As Decimal
Get
Return ViewState("TotAnt").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("TotAnt") = value
End Set
End Property
Private Property TotalOriginal As Double
Get
Return ViewState("TotalOriginal").ToString().ToDouble
End Get
Set(value As Double)
ViewState("TotalOriginal") = value
End Set
End Property
Private Property AplicaCancelarRemision As Boolean
Get
Return CBool(ViewState("AplicaCancelarRemision").ToString())
End Get
Set(value As Boolean)
ViewState("AplicaCancelarRemision") = value
End Set
End Property
Private Property TipoVentaSucursal As Integer
Get
Return ViewState("TipoVentaSucursal").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("TipoVentaSucursal") = value
End Set
End Property
Private Property MensajeCveSAT As StringBuilder
Get
If ViewState("MensajeCveSAT") Is Nothing Then ViewState("MensajeCveSAT") = New StringBuilder
Return CType(ViewState("MensajeCveSAT"), StringBuilder)
End Get
Set(value As StringBuilder)
ViewState("TipoVentaSucursal") = value
End Set
End Property
Private Property EditoRemision As Boolean
Get
Return CBool(ViewState("EditoRemision").ToString())
End Get
Set(value As Boolean)
ViewState("EditoRemision") = value
End Set
End Property
Private Property AplicaNC As Boolean
Get
Return CBool(ViewState("AplicaNC").ToString())
End Get
Set(value As Boolean)
ViewState("AplicaNC") = value
End Set
End Property
Private Property DtVentasNC As DataTable
Get
Return CType(ViewState("DtVentasNC"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtVentasNC") = value
End Set
End Property
Private Property AplicaNCMasiva As Boolean
Get
Return CBool(ViewState("AplicaNCMasiva").ToString())
End Get
Set(value As Boolean)
ViewState("AplicaNCMasiva") = value
End Set
End Property
Private Property RefacturacionGeneroNC As Boolean
Get
Return CBool(ViewState("RefacturacionGeneroNC").ToString())
End Get
Set(value As Boolean)
ViewState("RefacturacionGeneroNC") = value
End Set
End Property
Private Property ModalidadEdicion As Boolean
Get
Return CBool(ViewState("ModalidadEdicion").ToString())
End Get
Set(value As Boolean)
ViewState("ModalidadEdicion") = value
End Set
End Property
Private Property ConversionRemision As String
Get
Return ViewState("ConversionRemision").ToString()
End Get
Set(value As String)
ViewState("ConversionRemision") = value
End Set
End Property
Private Property TipoCambioRemision As Decimal
Get
Return ViewState("TipoCambioRemision").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("TipoCambioRemision") = value
End Set
End Property
Private Property TieneContrato As Boolean
Get
Return CBool(ViewState("TieneContrato").ToString())
End Get
Set(value As Boolean)
ViewState("TieneContrato") = value
End Set
End Property
Private Property CveOrdenCompraContrato As Integer
Get
Return ViewState("CveOrdenCompraContrato").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveOrdenCompraContrato") = value
End Set
End Property
Private Property ContratosConOC As StringBuilder
Get
If ViewState("ContratosConOC") Is Nothing Then ViewState("ContratosConOC") = New StringBuilder
Return CType(ViewState("ContratosConOC"), StringBuilder)
End Get
Set(value As StringBuilder)
ViewState("ContratosConOC") = value
End Set
End Property
Private Property RequiereOC As Boolean
Get
Return CBool(ViewState("RequiereOC").ToString())
End Get
Set(value As Boolean)
ViewState("RequiereOC") = value
End Set
End Property
Private Property PorcentajeCredito As Decimal
Get
Return ViewState("PorcentajeCredito").ToString().ToDecimal
End Get
Set(value As Decimal)
ViewState("PorcentajeCredito") = value
End Set
End Property
Private Property CvePedidoA As Integer
Get
Return ViewState("CvePedidoA").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePedidoA") = value
End Set
End Property
Private Property CveAcercamiento As Integer
Get
If ViewState("CveAcercamiento") Is Nothing Then
ViewState("CveAcercamiento") = -1
End If
Return ViewState("CveAcercamiento").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAcercamiento") = value
End Set
End Property
Private Property CveEmpresaCRM As Integer
Get
Return ViewState("CveEmpresaCRM").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveEmpresaCRM") = value
End Set
End Property
Private Property CveAcercamientoCRM As Integer
Get
Return ViewState("CveAcercamientoCRM").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAcercamientoCRM") = value
End Set
End Property
Private Property CorreoContactoCRM As String
Get
If ViewState("CorreoContactoCRM") Is Nothing Then
ViewState("CorreoContactoCRM") = ""
End If
Return ViewState("CorreoContactoCRM").ToString()
End Get
Set(value As String)
ViewState("CorreoContactoCRM") = value
End Set
End Property
Private Property DtPedidos2 As DataTable
Get
Return CType(ViewState("DtPedidos2"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPedidos2") = value
End Set
End Property
Private Property DtPedidos2PS As DataTable
Get
Return CType(ViewState("DtPedidos2PS"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPedidos2PS") = value
End Set
End Property
Private Property CveEstatus As Integer
Get
Return ViewState("CveEstatus").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveEstatus") = value
End Set
End Property
Private Property CveEstatusCotizacion As Integer
Get
Return (IfNull(ViewState("CveEstatusCotizacion"), "-1", ViewState("CveEstatusCotizacion"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveEstatusCotizacion") = value
End Set
End Property
Private Property CveMetodoPago33Venta As Integer
Get
Return (IfNull(ViewState("CveMetodoPago33Venta"), "-1", ViewState("CveMetodoPago33Venta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveMetodoPago33Venta") = value
End Set
End Property
Private Property CveFormaPago33Venta As Integer
Get
Return (IfNull(ViewState("CveFormaPago33Venta"), "-1", ViewState("CveFormaPago33Venta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveFormaPago33Venta") = value
End Set
End Property
Private Property CveMetodoPago33Cliente As Integer
Get
Return If(IsNothing(ViewState("CveMetodoPago33Cliente")), -1, ViewState("CveMetodoPago33Cliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveMetodoPago33Cliente") = value
End Set
End Property
Private Property CveFormaPago33Cliente As Integer
Get
Return If(IsNothing(ViewState("CveFormaPago33Cliente")), -1, ViewState("CveFormaPago33Cliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveFormaPago33Cliente") = value
End Set
End Property
Private Property CveVendedorVenta As Integer
Get
Return (IfNull(ViewState("CveVendedorVenta"), "-1", ViewState("CveVendedorVenta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveVendedorVenta") = value
End Set
End Property
Private Property CveVendedorCliente As Integer
Get
Return If(IsNothing(ViewState("CveVendedorCliente")), -1, ViewState("CveVendedorCliente")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveVendedorCliente") = value
End Set
End Property
Private Property CveVendedorClienteSucursal As Integer
Get
Return If(IsNothing(ViewState("CveVendedorClienteSucursal")), -1, ViewState("CveVendedorClienteSucursal")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveVendedorClienteSucursal") = value
End Set
End Property
Private Property CveVendedorContrato As Integer
Get
Return If(IsNothing(ViewState("CveVendedorContrato")), -1, ViewState("CveVendedorContrato")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveVendedorContrato") = value
End Set
End Property
Private Property CveVendedorEmpresaCRM As Integer
Get
Return If(IsNothing(ViewState("CveVendedorEmpresaCRM")), -1, ViewState("CveVendedorEmpresaCRM")).ToString().ToEntero
End Get
Set(value As Integer)
ViewState("CveVendedorEmpresaCRM") = value
End Set
End Property
Private Property DiasCredito As Integer
Get
Return ViewState("DiasCredito").ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("DiasCredito") = value
End Set
End Property
Private Property EsDiasCreditoFijo As Boolean
Get
Return CBool(ViewState("EsDiasCreditoFijo").ToString())
End Get
Set(value As Boolean)
ViewState("EsDiasCreditoFijo") = value
End Set
End Property
Private Property TieneDiasVencidos As Boolean
Get
Return CBool(IfNull(ViewState("TieneDiasVencidos"), "False", ViewState("TieneDiasVencidos")))
End Get
Set(value As Boolean)
ViewState("TieneDiasVencidos") = value
End Set
End Property
Private Property DiasVencidosCliente As Integer
Get
Return IfNull(ViewState("DiasVencidosCliente"), "0", ViewState("DiasVencidosCliente")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("DiasVencidosCliente") = value
End Set
End Property
Private Property SeCancelaRemisionProceso As Boolean
Get
Return CBool(ViewState("SeCancelaRemisionProceso").ToString())
End Get
Set(value As Boolean)
ViewState("SeCancelaRemisionProceso") = value
End Set
End Property
Private Property CvePrecioLista As Integer
Get
Return IfNull(ViewState("CvePrecioLista"), 0, ViewState("CvePrecioLista").ToString().ToEntero()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePrecioLista") = value
End Set
End Property
Private Property CvePrecioListaCliente As Integer
Get
Return IfNull(ViewState("CvePrecioListaCliente"), 0, ViewState("CvePrecioListaCliente").ToString().ToEntero()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CvePrecioListaCliente") = value
End Set
End Property
Private Property FacturarSucursal As Boolean
Get
Return CBool(IfNull(ViewState("FacturarSucursal"), "False", ViewState("FacturarSucursal")))
End Get
Set(value As Boolean)
ViewState("FacturarSucursal") = value
End Set
End Property
Private Property ClienteSucursal As Modelos.SucursalModel
Get
Return CType(ViewState("ClienteSucursal"), Modelos.SucursalModel)
End Get
Set(value As Modelos.SucursalModel)
ViewState("ClienteSucursal") = value
End Set
End Property
Private Property VentaDesglosaIEPS As Boolean
Get
Return CBool(IfNull(ViewState("VentaDesglosaIEPS"), "False", ViewState("VentaDesglosaIEPS")))
End Get
Set(value As Boolean)
ViewState("VentaDesglosaIEPS") = value
End Set
End Property
Private Property VentaNODesglosaIVA As Boolean
Get
Return CBool(IfNull(ViewState("VentaNODesglosaIVA"), "False", ViewState("VentaNODesglosaIVA")))
End Get
Set(value As Boolean)
ViewState("VentaNODesglosaIVA") = value
End Set
End Property
Private Property SerieVenta As String
Get
Return IfNull(ViewState("SerieVenta"), "", ViewState("SerieVenta")).ToString()
End Get
Set(value As String)
ViewState("SerieVenta") = value
End Set
End Property
Private Property AplicaDocumentoNuevoNC As Boolean
Get
Return CBool(IfNull(ViewState("AplicaDocumentoNuevoNC"), "False", ViewState("AplicaDocumentoNuevoNC")))
End Get
Set(value As Boolean)
ViewState("AplicaDocumentoNuevoNC") = value
End Set
End Property
Private Property AplicaRNCXDetalle As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRNCXDetalle"), "False", ViewState("AplicaRNCXDetalle")))
End Get
Set(value As Boolean)
ViewState("AplicaRNCXDetalle") = value
End Set
End Property
Private Property AplicaRNCBonificacionXDetalle As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRNCBonificacionXDetalle"), "False", ViewState("AplicaRNCBonificacionXDetalle")))
End Get
Set(value As Boolean)
ViewState("AplicaRNCBonificacionXDetalle") = value
End Set
End Property
Private Property AplicaRelacionManual As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRelacionManual"), "False", ViewState("AplicaRelacionManual")))
End Get
Set(value As Boolean)
ViewState("AplicaRelacionManual") = value
End Set
End Property
Private Property TmpDTFacturasRelacionadas As DataTable
Get
If ViewState("TmpDTFacturasRelacionadas") IsNot Nothing Then
Return CType(ViewState("TmpDTFacturasRelacionadas"), DataTable)
Else
Return Nothing
End If
End Get
Set(value As DataTable)
ViewState("TmpDTFacturasRelacionadas") = value
End Set
End Property
Private Property CveAutorizacion As Integer
Get
Return (IfNull(ViewState("CveAutorizacion"), "-1", ViewState("CveAutorizacion"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveAutorizacion") = value
End Set
End Property
Private Property EsGarantia As Boolean
Get
Return CBool(IfNull(ViewState("EsGarantia"), False, ViewState("EsGarantia")))
End Get
Set(value As Boolean)
ViewState("EsGarantia") = value
End Set
End Property
Private Property TipoCambioOriginal As Decimal
Get
Return (IfNull(ViewState("TipoCambioOriginal"), 0, ViewState("TipoCambioOriginal"))).ToString().ToDecimal()
End Get
Set(value As Decimal)
ViewState("TipoCambioOriginal") = value
End Set
End Property
Private Property DtMercancias As DataTable
Get
Return If(IsNothing(ViewState("DtMercancias")), Nothing, CType(ViewState("DtMercancias"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtMercancias") = value
End Set
End Property
Private Property ClienteCodigoRegimenFiscal As String
Get
If ViewState("ClienteCodigoRegimenFiscal") Is Nothing Then
ViewState("ClienteCodigoRegimenFiscal") = ""
End If
Return ViewState("ClienteCodigoRegimenFiscal").ToString
End Get
Set(value As String)
ViewState("ClienteCodigoRegimenFiscal") = value
End Set
End Property
Private Property ClienteRegimenFiscal As String
Get
If ViewState("ClienteRegimenFiscal") Is Nothing Then
ViewState("ClienteRegimenFiscal") = ""
End If
Return ViewState("ClienteRegimenFiscal").ToString
End Get
Set(value As String)
ViewState("ClienteRegimenFiscal") = value
End Set
End Property
Private Property CveLineaAdicionalVenta As Integer
Get
Return IfNull(ViewState("CveLineaAdicionalVenta"), "-1", ViewState("CveLineaAdicionalVenta")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveLineaAdicionalVenta") = value
End Set
End Property
Private Property SaldoLineaAdicional As Decimal
Get
Return (IfNull(ViewState("SaldoLineaAdicional"), "0", ViewState("SaldoLineaAdicional"))).ToString().ToDecimal()
End Get
Set(value As Decimal)
ViewState("SaldoLineaAdicional") = value
End Set
End Property
Private Property SaldoIngresosLineaAdicional As Decimal
Get
Return (IfNull(ViewState("SaldoIngresosLineaAdicional"), "0", ViewState("SaldoIngresosLineaAdicional"))).ToString().ToDecimal()
End Get
Set(value As Decimal)
ViewState("SaldoIngresosLineaAdicional") = value
End Set
End Property
Private Property CveCategoriaLineaAdicional As Integer
Get
Return IfNull(ViewState("CveCategoriaLineaAdicional"), "-1", ViewState("CveCategoriaLineaAdicional")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveCategoriaLineaAdicional") = value
End Set
End Property
Private Property CveMonedaLineaAdicional As Integer
Get
Return IfNull(ViewState("CveMonedaLineaAdicional"), "-1", ViewState("CveMonedaLineaAdicional")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveMonedaLineaAdicional") = value
End Set
End Property
Private Property HabilitoFacturacionIngresoLineaAdicional As Boolean
Get
Return If(IsNothing(ViewState("HabilitoFacturacionIngresoLineaAdicional")), False, CType(ViewState("HabilitoFacturacionIngresoLineaAdicional"), Boolean))
End Get
Set(value As Boolean)
ViewState("HabilitoFacturacionIngresoLineaAdicional") = value
End Set
End Property
Private Property CveContratoTipo As Integer
Get
Return IfNull(ViewState("CveContratoTipo"), "-1", ViewState("CveContratoTipo")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveContratoTipo") = value
End Set
End Property
Private Property HabilitaRemisionPublicoGeneral As Integer
Get
Return IfNull(ViewState("HabilitaRemisionPublicoGeneral"), "0", ViewState("HabilitaRemisionPublicoGeneral")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("HabilitaRemisionPublicoGeneral") = value
End Set
End Property
Private Property TieneBloqueoPorAutorizacion As Integer
Get
Return IfNull(ViewState("TieneBloqueoPorAutorizacion"), "0", ViewState("TieneBloqueoPorAutorizacion")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("TieneBloqueoPorAutorizacion") = value
End Set
End Property
Public Property IndicePSActual As Integer
Get
Return IfNull(ViewState("IndicePSActual"), "-1", ViewState("IndicePSActual")).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("IndicePSActual") = value
End Set
End Property
Public Property CantidadOriginal As Decimal
Get
Return IfNull(ViewState("CantidadOriginal"), "-1", ViewState("CantidadOriginal")).ToString().ToDecimal()
End Get
Set(value As Decimal)
ViewState("CantidadOriginal") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Modalidad = ""
Opcion = ""
Index = 0
TotAnt = 0
'CargoComercioExterior = False
' DdlBPPS.setEsWebService(True)
'DdlBPPS.ddlWS.Attributes.Add("data-clear", "1")
ViewState("ProcesoCorrecto") = True
ViewState("CargoUsado") = True
ViewState("NuevaFactura") = -1
ViewState("CveDevolucion") = -1
ViewState("CvePedido") = -1
ViewState("CvePedido2") = -1
ViewState("TipoContrato") = -1
ViewState("CveVenta") = -1
ViewState("CveCliente") = -1
ViewState("CveClienteAnterior") = -1
ViewState("CveOS") = -1
ViewState("CveOC") = -1
ViewState("CveAnticipo") = -1
ViewState("CveFactura") = -1
ViewState("CveCicloComercial") = -1
ViewState("Entrega") = ""
ViewState("Vigencia") = ""
ViewState("AplicarVentaFacturada") = False
ViewState("SeGuardoPrePoliza") = False
ViewState("TipoDoctoDevolucion") = ""
ViewState("EditoRemision") = False
ViewState("RequiereOC") = False
ViewState("ClienteDesglosaIEPS") = False
ViewState("ClienteNODesglosaIVA") = False
ViewState("ClienteRetIVA") = 0
ViewState("ClienteRetISR") = 0
ViewState("CvePrecioLista") = 0
ViewState("CvePrecioListaCliente") = 0
HdnCargarInventario.Value = "True"
Me.CveVendedorVenta = -1
Me.CveVendedorCliente = -1
Me.CveVendedorClienteSucursal = -1
Me.CveVendedorContrato = -1
Me.CveVendedorEmpresaCRM = -1
Me.EsGarantia = False
CveEmpresaCRM = 0
CveAcercamientoCRM = 0
EstatusCliente = False
RemisionesLista = New List(Of Integer)
Pedidos2Lista = New List(Of Integer)
CotizacionesLista = New List(Of Integer)
ListaDescuentos = New List(Of Modelos.VentaDescuentos)
CuentasContablesInvalidas = New StringBuilder
CvePrePoliza = 0
TotalOtrosConceptos = 0
CveUsuarioActual = UsuarioActual.CveUsuario
EmpresaActual = UsuarioActual.Empresa
IdPoliza = 0
CveCorte = -1
CveContrato = -1
DevolucionAlmacen = 0
CvePSAmortizacion = 0
EraCotizacion = 0
FacturaMateriales = 0
CvePedidoA = 0
EsCreaApartirDe = False
RequiereAlmacenDestino = False
RequiereAlmacenOrigen = False
TmpDTComplementos = New DataTable
DtRemConceptosSurtidos = Nothing
TipoVentaSucursal = 0
PlazoCobranza = 0
PlazoCobranzaRemision = 0
TipoCambioFactura = 1
NumeroContrato = ""
DescripcionContrato = ""
NumeroLicitacion = ""
ImprimeNombreSucursal = False
RegistraScript("SetDisabledTxtTotal(true);")
TrVistaPrevia.Visible = False
'CveMetodoPagoCliente = 1
CveAlmacenExistenciasContrato = -1
UpFacturar.Update()
'CargaTiposDocumentos()
TrEmitir.Visible = False
ViewState("EstablecioFolio") = False
'ViewState("SubProyectoPorcentajeIVA") = 0
RefacturacionGeneroNC = False
ModalidadEdicion = False
ConversionRemision = ""
TipoCambioRemision = 1
CveOrdenCompraContrato = -1
TieneContrato = False
AplicaNC = False
TieneAlmacen = False
CveEstatus = -1
PorcentajeIVA = 0
EsDiasCreditoFijo = False
DiasCredito = 0
AplicaCancelarRemision = False
SeCancelaRemisionProceso = False
TotalOriginal = 0
CveAlmacenDevolucion = 0
Me.CveEstadoCancelacion = 0
'TxtFechaOS.Text = NowADS().ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
If UsuarioActual.TienePermisoProceso(177) Then
DdlTipoComprobante.Items.Insert(4, New ListItem("Pedido de Contrato", "Ped"))
End If
If Not UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
LnkAgregarCliente.Visible = False
End If
DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("Pedido", "Pd2"))
If UsuarioActual.Empresa.Funcionalidad(344).ToString() = "1" Then
DdlTipoComprobante.Items.Insert(DdlTipoComprobante.Items.Count, New ListItem("NC de Remisión", "RNC"))
End If
SetValues()
CvePresupuesto = 0
'MODALIDADES
If Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then
Opcion = Request("Op").ToString()
LblTitulo.Text = "Registro de Cotizaciones"
TrTipo.Visible = False
divcondicionespago.Visible = UsuarioActual.Empresa.CvePlataforma = 1 'SI ES PLATAFORMA ERP SIEMPRE VSIBLE ESTE PORLET
ImgAntiPend.Visible = False
TrOC.Visible = False
DdlTipoComprobante.SelectedValue = "Op"
Else
Opcion = "Ing"
DdlTipoComprobante.SelectedValue = "Ing"
End If
LblUsuario.Text = UsuarioActual.Usuario
LblFechaRegistro.Text = NowADS().ToShortDateString()
ImgDescTotal.Visible = False
ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';")
ImgAntiPend.Attributes.Add("onclick", "$get('HdnTipoDescuento').value = '3'; MuestraAnticipos();")
ImgOtrosConceptos.Attributes.Add("onclick", "javascript:$('#ModalOtrosConceptos').modal();")
CreaDTmpC()
CreaDTmpF()
CreaDTDocumentosRelacionados()
CargaDdlSubProyectos()
'CargaProyecto()
'CargaSucursales()
CargaClasificaciones()
CargaPS(-1, DdlPS)
CreaDTVentas()
CargaMetodosPago()
CargaUsoCFDI()
CargaMonedas()
CargaAgentes()
CargaProcedimientos()
CargaTiposVenta()
CargaDdlClientes()
'SI USUARIO USA AMORTIZACIÓN CONTABLE, se carga las tablas para usarlas mas adelante
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot"))
DdlTipoComprobante.Items.Add(New ListItem("Compromisos", "Com"))
DdlTipoComprobante.Items.Add(New ListItem("Orden Pago", "OP"))
Dim AC As New ClsAC
If AC.GetPresupuestoIngresos(-1, NowADS().Year, True, UsuarioActual.CveEmpresa) Then
DdlFuenteRecaudacion.DataSource = AC.DtResultados()
DTPresupuestoIngresos = AC.DtResultados()
ViewState("DTFuenteRecaudacion") = AC.DtResultados()
'GenerarPolizasAC()
End If
AC.Dispose()
'columna de Fuente de recaudacion
GvPS.Columns(21).Visible = True
'nomostrar.Visible = True
'nomostrar2.Visible = True
'GvPS.Width = 1250
DdlFuenteRecaudacion.DataBind()
Else
TFuenteRecaudacion.Visible = False
End If
'Carga cliente
If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero() > 0 AndAlso Request("CveFactura") Is Nothing Then
ViewState("CveCliente") = Request("CveCliente")
HdnCveCliente.Value = Request("CveCliente")
CargaCliente(CveCliente)
Else
ViewState("CveCliente") = -1
HdnCveCliente.Value = "-1"
End If
'Carga empresa CRM
If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero() > 0 Then
ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM")
CargaEmpresaCRM(CveEmpresaCRM)
Else
ViewState("CveEmpresaCRM") = -1
End If
If Request("CveAcercamientoCRM") IsNot Nothing AndAlso IsNumeric(Request("CveAcercamientoCRM")) AndAlso Request("CveAcercamientoCRM").ToEntero() > 0 Then
ViewState("CveAcercamientoCRM") = Request("CveAcercamientoCRM")
Dim cRMService As ICRMService = New CRMService(System.Configuration.ConfigurationManager.ConnectionStrings("Conexion").ConnectionString)
Dim AcercamientoModel As New RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamientoCRM)
Dim objAcercamiento = cRMService.GetAceracamientoCRM(AcercamientoModel)
If objAcercamiento.Result.Count > 0 Then
CorreoContactoCRM = objAcercamiento.Result(0).CorreoContacto
End If
Else
ViewState("CveAcercamientoCRM") = -1
End If
'mensaje de confirmación al guardar
BtnEmitirImprimir.OnClientClick = $"ValidaGuardar({ If(ImprimeNombreSucursal = True, 1, 0)},0);"
BtnEmitirImprimir.Attributes.Add("data-toggle", "confirmation")
BtnEmitirImprimir.Attributes.Add("data-popout", "true")
BtnEmitirImprimir.Attributes.Add("data-original-title", "confirmar")
BtnEmitirImprimir.Attributes.Add("data-btn-ok-label", "Guardar")
BtnEmitirImprimir.Attributes.Add("data-html", "true")
If UsuarioActual.CveEmpresa.Contiene(126) Then ' cuando la empresa se relaciona a ua orden de producción, Citrus Game
TrOP.Visible = True
CargaOrdenProduccion()
End If
If Request("CveOrdenProduccion") IsNot Nothing AndAlso IsNumeric(Request("CveOrdenProduccion")) AndAlso Request("CveOrdenProduccion").ToEntero() > 0 Then
DdlSubProyectoDatos.SelectedValueExist(11954)
Using ObjVentas As New ClsNominas
If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", -Request("CveOrdenProduccion").ToEntero()) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
TmpDT.Columns.Add("CveMarca", GetType(Integer))
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
TmpDT.Columns.Add("NumTurnos", GetType(Decimal))
TmpDT.Columns("NumTurnos").DefaultValue = 0D
TmpDT.Columns.Add("NumeroPedimento", GetType(String))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
'IEPS A NIVEL DETALLE
'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text)
End If
End Using
End If
If Request("CveEmbarqueManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveEmbarqueManifiesto")) AndAlso Request("CveEmbarqueManifiesto").ToEntero() > 0 Then
DdlMoneda.SelectedValueExist(2)
CambiaMoneda()
Using ObjVentas As New ClsNominas
If ObjVentas.EmbarqueManifiestoGet(-1, -1, -1, Request("CveEmbarqueManifiesto").ToString().ToEntero()) And ObjVentas.DtResultados.Rows.Count > 0 Then
DdlSubProyectoDatos.SelectedValueExist(ObjVentas.DtResultados.Rows(0)("CveSubProyecto").ToString())
End If
If ObjVentas.ManifiestoForVtaGet(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, "", Request("CveEmbarqueManifiesto").ToEntero()) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
TmpDT.Columns.Add("CveMarca", GetType(Integer))
TmpDT.Columns.Add("CvePrecioLista", GetType(Integer))
TmpDT.Columns.Add("PrecioLista", GetType(String))
TmpDT.Columns.Add("CveActivoFijo", GetType(Integer))
TmpDT.Columns.Add("AFDepreciacion", GetType(Decimal))
TmpDT.Columns.Add("AFValorInicial", GetType(Decimal))
TmpDT.Columns.Add("NumTurnos", GetType(Decimal))
TmpDT.Columns("NumTurnos").DefaultValue = 0D
TmpDT.Columns.Add("NumeroPedimento", GetType(String))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
'IEPS A NIVEL DETALLE
'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text)
End If
End Using
End If
'SI ES VENTA NUEVA, NO RECARGAR TAB DE ALMACEN
If CveVenta <= 0 Then
'REMOVER EVENTO PARA RECARGAR ALMACEN
HdnCargarInventario.Value = "False"
'spanAlmacen.Attributes.Remove("onclick")
UpParametros.Update()
End If
CargaEstatusFactura(Opcion)
If Opcion = "Ing" Then
'DdlEstatus.Enabled = False
If UsuarioActual.Empresa.TipoFacturacion = "CBB" Then
'DdlEstatus.SelectedValue = "3"
CveEstatus = 3
ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" Then
'DdlEstatus.SelectedValue = "2"
CveEstatus = 2
End If
End If
'CARGA PARA FACTURAR
ViewState("CveRemision") = IfNull(Request("CveRemision").ToEntero(), 0)
ViewState("CveCotizacion") = IfNull(Request("CveCotizacion").ToEntero(), 0)
'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then
' EsCreaApartirDe = True
'End If
If ViewState("CveRemision").ToString().ToEntero() > 0 Or ViewState("CveCotizacion").ToString().ToEntero() > 0 Then
ImgAddObs.Visible = True
CargaEventoBitacora()
DdlTipoComprobante.Enabled = False
DdlTipoComprobante.SelectedValue = "Ing"
CargaEstatusFactura()
'DdlEstatus.SelectedValueExist("2")
ConfiguraTipoDocto()
BtnEmitirImprimir.Text = "Facturar"
BtnEmitirImprimir.Visible = True
UpnTools.Update()
End If
If Not ExFolioFactura Then SetPermisos()
If CveVenta < 1 Then CargaFolios()
If CveVenta <= 0 AndAlso UsuarioActual.CveEmpresa.Contiene(7, 122) Then
TxtCantidad.Width = New Unit("100%")
End If
InicializaImprimirNew()
TxtSubTotal.Attributes.Add("onKeyUp", "FnSuma()")
TxtIVA.Attributes.Add("onKeyUp", "FnSuma()")
TxtIEPS.Attributes.Add("onKeyUp", "FnSuma()")
TxtRetIVA.Attributes.Add("onKeyUp", "FnSuma()")
TxtRetISR.Attributes.Add("onKeyUp", "FnSuma()")
CargaFormatoSucursal()
'SELECCIONA SUCURSAL DEL USUARIO CUANDO SEA VENTA NUEVA Y SIN CLIENTE
If Not (CveCliente > 0 Or CveVenta > 0) Then
DdlSubProyectoDatos.SelectedValueExist(UsuarioActual.CveSubProyecto)
If UsuarioActual.TienePermisoProceso(152) Then
DdlSubProyectoDatos.Enabled = False
End If
CambiaSucursal()
UpParametros.Update()
End If
'CUANDO SEA COTIZACION Y SEA COMPUPROVEEDORES (EMPRESA 72) NO DEBE ENVIAR CORREO AL CLIENTE
EnviarCorreoCliente = True
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
EnviarCorreoCliente = False
End If
'MOSTRAR LA OPCION DE AGREGAR PS EN BDH
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveVenta <= 0 Then
ImgOtrosConceptos.Visible = False
GvPS.Columns(8).Visible = False
For Each Gvr As GridViewRow In GvPS.Rows
Gvr.FCLinkButton("imgE").Visible = False
Next
End If
If UsuarioActual.Empresa.CvePlataforma = 2 Then
ImgOtrosConceptos.Visible = False
GvPS.Columns(8).Visible = False
For Each Gvr As GridViewRow In GvPS.Rows
Gvr.FCLinkButton("imgE").Visible = False
Gvr.FCLinkButton("imgEPyME").Visible = True
Next
End If
If Request("CveVenta") IsNot Nothing AndAlso IsNumeric(Request("CveVenta")) AndAlso Request("CveVenta").ToEntero() = -1 AndAlso UsuarioActual.CveTipoDocumento.Length = 3 Then
CargaDdlSubProyectos()
UpParametros.Update()
DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento)
CambiaTipoDocto()
End If
If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString() = "1" Then
If (DdlTipoComprobante.Items.FindByValue("Ing") IsNot Nothing) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
End If
End If
LtlTareaNueva.Text = String.Format(" Tarea", CveVenta)
'SI ESTA CARGANDO UNA REFACTURACION. VALIDAR QUE LA FACTURA ANTERIOR ESTE CANCELADA
If Me.ObjFacturaNC IsNot Nothing Then
If Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1 Then
Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.ObjFacturaNC.CveEstatusFactura}").ToEntero()
If TipoEstatus <> 5 Then
'ESTATUS DE CANCELACION PENDIENTE
If Not Me.ObjFacturaNC.CveEstatusFactura = 23 Then
Alert($"El documento de tipo '{Me.ObjFacturaNC.TipodeComprobante}' a refacturar no ha sido cancelado. Favor de verificar el documento", TipoMensaje.MsgAdvertencia)
BtnEmitirImprimir.Visible = False
UpFacturar.Update()
End If
End If
End If
End If
'VALIDA ESTATUS CLIENTE - SOLO SE PUEDE USAR EL CLIENTE PARA COTIZAR EN CASO DE ESTAR INACTIVO
If Not CveVenta > 0 AndAlso Not BtnEmitirImprimir.Visible AndAlso Request("Op") IsNot Nothing AndAlso Request("Op").ToString() <> "" Then
If DdlTipoComprobante.SelectedValue.Contiene("Cot") Then
BtnEmitirImprimir.Visible = True
TrVistaPrevia.Visible = True
End If
End If
If Request("CveCotizacion") IsNot Nothing AndAlso IfNull(Request("CveCotizacion"), 0).ToString().ToEntero() > 0 Then
If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then
'VERIFICA SI NO ESTA AUTORIZADA
If CveEstatusCotizacion <> 8 Then
BtnEmitirImprimir.Enabled = False
BtnEmitirImprimir.Visible = False
Alert("La cotización no esta autorizada", TipoMensaje.MsgAdvertencia)
End If
End If
End If
If DdlTipoComprobante.SelectedValue.Contiene("Rem") Then
' IPP 15 Julio 2017 - ERA FALSE
ImgAntiPend.Visible = False
UpPS.Update()
End If
BloqueaCondiconesPago()
End If
End Sub
Private Sub CargaDdlClientes()
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
DdlClientesWS.setEsWebService(True)
Else
DdlClientesWS.setEsWebService(False)
If Not UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
DdlClientesWS.ddl.Items.Clear()
DdlClientesWS.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
DdlClientesWS.DataBind()
DdlClientesWS.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
End If
End Sub
Private Sub BloqueaClasificaciones()
If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
DdlClasificacion.Enabled = False
DdlUnidadMedida.Enabled = False
End If
End Sub
Private Sub BloqueaCondiconesPago()
If UsuarioActual.TienePermisoProceso(289) Then
DdlUsoCFDI.Enabled = False
DdlMetodoPago33.Enabled = False
DdlFormaPago33.Enabled = False
DdlTiposRelacion.Enabled = False
End If
UPCondicionesPago.Update()
End Sub
Private Sub ConfiguraEmpresa()
Select Case UsuarioActual.CveEmpresa
Case 119
TxtObsPS.Attributes.Add("onkeypress", "setFocus(event,'TxtPrecio');")
End Select
End Sub
#Region "C A R G A S"
Private Sub CargaOrdenProduccion(Optional Opcion As Integer = 1, Optional CveVenta As Integer = -1)
DdlOrdenProduccion.Items.Clear()
Dim CveOrdenProduccion As String = "-1"
Dim ObjCGame As New ClsCGame
If ObjCGame.GetOrdenProduccion(-1, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Then
If Opcion = 1 Then
DdlOrdenProduccion.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("CveVenta IS NULL "))
ElseIf Opcion = 2 Then
LnkActualizarOrdenProduccion.Visible = True
DdlOrdenProduccion.DataSource = ObjCGame.DtResultados.FiltraParametros($"CveVenta = {CveVenta} OR CveVenta IS NULL")
If ObjCGame.DtResultados.FiltraParametros($"CveVenta = {CveVenta}").Rows.Count > 0 Then
CveOrdenProduccion = ObjCGame.DtResultados.FiltraParametros($"CveVenta = {CveVenta}").Rows(0)("CveOrdenProduccion").ToString()
End If
End If
DdlOrdenProduccion.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
ObjCGame.Dispose()
DdlOrdenProduccion.DataBind()
DdlOrdenProduccion.SelectedValueExist(CveOrdenProduccion)
End Sub
Private Sub CargaEstatusFactura(Optional TipoDocto As String = "Ing")
Dim FiltroCompromiso As String = If(TipoDocto = "Com", "And CveEstatusFactura In (2, 9)", "And CveEstatusFactura Not In (9)")
If TipoDocto.ToUpper.Contiene("EGS", "COM", "ANT") Then TipoDocto = "Ing"
End Sub
Private Sub CargaOS(CveOS As Integer)
Dim OS As New ClsOS
Dim DtDetalle As DataTable = Nothing
Dim DtDetalleMateriales As DataTable = Nothing
If OS.GetOrdenesServicios(CveOS, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
HdnCveCliente.Value = OS.CveCliente.ToString()
ViewState("CveCliente") = OS.CveCliente
CargaCliente(CveCliente)
If OS.GetOrdenesServiciosDetalleAFacturar(CveOS) Then
Dim Cons As Integer = 1
For Each dr As DataRow In OS.DtResultados.FiltraParametros("SeFacturara = 1 ").Rows
AgregarProductoServicio(dr("Cantidad").ToString().ToDecimal, dr("CveUM").ToString().ToEntero(), dr("UM").ToString(), -1, "", dr("CvePS").ToString().ToEntero(), "", dr("Obs").ToString(), dr("PU").ToString().ToDecimal, 0, -1, "",
dr("CveSubProyecto").ToString().ToEntero(), dr("SubProyecto").ToString())
'Dim drt As DataRow = TmpDT.NewRow
'drt("Consec") = Cons
'drt("CvePS") = dr("CvePS")
'drt("CveClasificacion") = dr("CveClasificacion")
'drt("Clasificacion") = dr("Clasificacion")
'drt("PS") = dr("PS")
'drt("CveOSDetalle") = dr("CveOSDetalle")
'drt("CodigoPS") = dr("CodigoPS")
'drt("Cantidad") = dr("Cantidad")
'drt("CveSubProyecto") = dr("CveSubProyecto")
'drt("SubProyecto") = dr("SubProyecto")
'drt("Obs") = dr("Obs")
'TmpDT.Rows.Add(drt)
'Cons = Cons + 1
Next
TmpDT.AcceptChanges()
DtDetalle = OS.DtResultados.FiltraParametros("SeFacturara = 1 ")
End If
For Each Row As DataRow In DtDetalle.Rows
If OS.GetDetalleMateriales(Row("CveOSDetalle").ToString().ToEntero(), CveOS) Then
If OS.DtResultados.FiltraParametros("SeFacturara = 1").Rows.Count > 0 Then
Alert("Hay materiales en la Orden de Servicio, ¿Desea facturar los materiales?", TipoMensaje.MsgConfirmacion, "BtnMateriales()")
End If
End If
Next
OS.Dispose()
CalculaTotalesVenta(False)
GvPS.DataSource = TmpDT
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind()
'JJMQ 20160506: Se agrego para la validacion de pago de contado.
'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "")
UpPS.Update()
End If
End Sub
Private Sub CargaTiposDocumentos()
DdlTipoComprobante.DataSource = GlobalDTTiposDocumentos()
DdlTipoComprobante.DataBind()
End Sub
Private Sub CargaNuevaFactura(OVenta As ClsVentas)
Dim ObjVentas As ClsVentas
If OVenta IsNot Nothing Then
ObjVentas = OVenta
Else
ObjVentas = New ClsVentas()
End If
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
Dim drv As DataRow = ObjVentas.DtResultados.Rows(0)
'CargaCliente
Dim CveCliente As Integer = drv("CveCliente").ToString().ToEntero()
HdnCveCliente.Value = CveCliente.ToString()
ViewState("CveCliente") = CveCliente
CargaCliente(CveCliente)
DdlSucursalCliente.SelectedValueExist(drv("CveClienteSucursal").ToString())
DdlSubProyectoDatos.SelectedValueExist(drv("CveSubProyecto").ToString())
If CveDevolucion > 0 Then
CambiaSucursalGeneral()
End If
CargaClienteSucursal(drv("CveClienteSucursal").ToString().ToEntero())
'CargaDetalle
If ObjVentas.GetVentaDetalle(CveVenta) Then
For Each dr As DataRow In ObjVentas.DtResultados.Rows
AgregarProductoServicio(dr("Cantidad").ToString().ToDecimal, dr("CveUM").ToString().ToEntero(), dr("UM").ToString(), dr("CveClasificacion").ToString().ToEntero(), dr("Clasificacion").ToString(),
dr("CvePS").ToString().ToEntero(), dr("PS").ToString(), dr("Obs").ToString(), dr("PU").ToString().ToDecimal, dr("Descuento").ToString().ToDecimal,
dr("CveProyecto").ToString().ToEntero(), dr("Proyecto").ToString(), dr("CveSubProyecto").ToString().ToEntero(), dr("SubProyecto").ToString(),
CveContratoDetalle:=dr("CveContratoDetalle").ToString().ToEntero(), CveVentaDetalleCotizacion:=dr("CveVentaDetalleCotizacion").ToString().ToEntero(),
CveVentaDetalle:=dr("CveVentaDetalle").ToString().ToEntero(), RegeneraIEPS:=False, SeActualiza:=True)
Next
ObjVentas.DtResultados.Columns.Add("TieneProntoPago", GetType(String))
ObjVentas.DtResultados.Columns.Add("ImporteProntoPago", GetType(Decimal))
ObjVentas.DtResultados.Columns("TieneProntoPago").DefaultValue = "No"
ObjVentas.DtResultados.Columns("ImporteProntoPago").DefaultValue = 0
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
End If
'CARGA IMPUESTOS LOCALES
If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
TrOtros.Visible = True
TmpDTImpuestos = ObjVentas.DtResultados
GvImpuestosLocales2.DataSource = ObjVentas.DtResultados
GvImpuestosLocales2.DataBind()
If (NuevaFactura = 1) Then
GvImpuestosLocales2.Enabled = True
Else
GvImpuestosLocales2.Enabled = False
End If
GvImpuestosLocales2.Visible = True
End If
End If
'Carga Totales
ViewState("TipoDoctoDevolucion") = drv("TipoDocto").ToString()
TxtSubTotal.Text = drv("SubTotal").ToString().FormatoNumero(2)
LblDescuentos.Text = drv("Descuento").ToString().FormatoNumero(2)
LblAmortizacion.Text = drv("Amortizacion").ToString().FormatoNumero(2)
TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2)
TxtIVA.Text = drv("IVA").ToString().FormatoNumero(2)
TxtRetIVA.Text = drv("RetIVA").ToString().FormatoNumero(2)
If TxtRetIVA.Text.ToDecimal() > 0 Then
TrRetIVA.Style.Add("display", "")
UsuarioActual.Empresa.MostrarRetIVA = True
End If
TxtRetISR.Text = drv("RetISR").ToString().FormatoNumero(2)
TxtTotal.Text = drv("Total").ToString().FormatoNumero(2)
TotalOriginal = Math.Round(drv("Total").ToString().ToDouble, 2)
HdnVentaSaldo.Value = drv("Total").ToString()
TxtObsFact.Text = drv("Observaciones").ToString()
DdlMoneda.SelectedValue = drv("CveMoneda").ToString()
CambiaMoneda()
TxtTipoCambio.Text = drv("TipoCambio").ToString()
CvePAC = drv("CvePAC").ToString().ToEntero()
DdlUsoCFDI.SelectedValueExist(drv("CveUsoCFDI").ToString())
DdlMetodoPago33.SelectedValueExist(drv("CveMetodoPago33").ToString())
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
DdlFormaPago33.SelectedValueExist(drv("CveFormaPago33").ToString())
DdlTipoComprobante.SelectedValueExist(drv("TipoDocto").ToString())
DdlTipoComprobante.Enabled = False
HdnIVAOriginal.Value = TxtIVA.Text
HdnAmortizacion.Value = "0" 'LblAmort.Text.ToDouble.ToString()
HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2)
'JJMQ 20160506: Se agrego para la validacion de pago de contado.
'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "")
CveContrato = drv("CveContrato").ToString().ToEntero()
Updatetabs.Update()
UpPS.Update()
End If
End If
If OVenta Is Nothing Then
ObjVentas.Dispose()
End If
End Sub
Private Sub CargaMetodosPago()
'FACTURACION 3.3
DdlMetodoPago33.DataSource = GlobalDTVtaMetodoPago
DdlMetodoPago33.DataBind()
DdlMetodoPago33.SelectedValueExist("3")
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
'End If
End Sub
Private Sub CargaFormaPago(CveMetodoPago As Integer)
Dim dtt As DataTable = Nothing
If CveMetodoPago > 0 Then
dtt = GlobalDTVtaFormaPago.FiltraParametros(If(CveMetodoPago = 1, " CveFormaPago <> 20 ", "CveFormaPago = 20"))
Else
dtt = GlobalDTVtaFormaPago
End If
DdlFormaPago33.Items.Clear()
DdlFormaPago33.DataSource = dtt
DdlFormaPago33.SelectedValue = dtt.FiltroPrimeroValor("CveFormaPago", "")
DdlFormaPago33.DataBind()
If UsuarioActual.CveRol = 1 AndAlso CveMetodoPago = 1 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso TbDescuentosAdicionales.Visible Then
If TmpDT.SUMD("Descuento") > 0 Then
Dim TotalDescuento As Decimal = TmpDT.SUMD("Total", "Descuento > 0") * 0.05D
Dim RowDescuentos As DataRow() = TmpDT.Select("Descuento > 0")
If RowDescuentos IsNot Nothing Then
LblDescuentoAdicional.Text = TotalDescuento.FormatoNumero(2)
CalculaTotalesVenta()
End If
Else
LblDescuentoAdicional.Text = "0.00"
End If
UpPS.Update()
End If
'End If
End Sub
Private Sub CargaUsoCFDI()
DdlUsoCFDI.Items.Clear()
'DdlSucursalUsoCFDI.Items.Clear()
Dim EsPersonaMoral As Boolean = (TipoPersona = True)
DdlUsoCFDI.DataSource = GlobalDTSATUsosCFDI(If(Not EsPersonaMoral, 1, 0), RegimenFiscalReceptor:=RegimenFiscalCliente)
'DdlSucursalUsoCFDI.DataSource = GlobalDTSATUsosCFDI(If(Not EsPersonaMoral, 1, 0), RegimenFiscalReceptor:=RegimenFiscalCliente)
DdlUsoCFDI.DataBind()
'DdlSucursalUsoCFDI.DataBind()
If Not UsuarioActual.CveEmpresa.Contiene(76, 15) Then
If DdlUsoCFDI.DataSource IsNot Nothing Then
If DdlUsoCFDI.Items.FindByValue("25") IsNot Nothing Then
DdlUsoCFDI.Items.Remove(DdlUsoCFDI.Items.FindByValue("25"))
End If
End If
End If
DdlUsoCFDI.Items.Insert(0, New ListItem("Seleccione", "-1"))
' DdlSucursalUsoCFDI.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargaMonedas()
DdlMoneda.DataSource = GlobalDTMonedas
DdlMoneda.DataBind()
End Sub
'Private Sub CargaProyecto()
' Dim CveSubProyecto As Integer = 0
' Dim dtt As DataTable = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1)
' DdlProyecto.DataSource = dtt
' DdlProyecto.DataBind()
'CveSubProyecto = GetSubProyectoSucursal()
' CargaSubProyecto(CveSubProyecto)
'End Sub
Private Function GetSubProyectoSucursal() As Integer
Dim Retorno As Integer = 0
'Dim dr As DataRow = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltroPrimero($"CveSubProyecto = {If(DdlSubProyectoDatos.SelectedValue = "", "-1", DdlSubProyectoDatos.SelectedValue)}")
''Dim dr As DataRow = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero($"CveSubProyecto = {If(DdlSubProyectoDatos.SelectedValue = "", "-1", DdlSubProyectoDatos.SelectedValue)}")
''si hay un proyecto relacionado con el subproyecto
'If dr IsNot Nothing AndAlso dr("CveSubProyecto").ToString().ToEntero() > 0 Then
' DdlProyecto.SelectedValueExist(dr("CveProyecto"))
' Retorno = dr("CveSubProyecto").ToString().ToEntero()
'End If
Return Retorno
End Function
'Private Sub CargarAlmacenes()
' If UsuarioActual.Empresa.UsaInventarios Then
' If (CveVenta > 0 And DdlTipoComprobante.SelectedValue <> "Cot") AndAlso Not (UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso EsCreaApartirDe) Then
' DivAlmacen.Visible = False
' Else
' Dim DTAlmacen As DataTable
' ddlAlmacen.Items.Clear()
' DTAlmacen = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()}")
' ddlAlmacen.DataSource = DTAlmacen
' ddlAlmacen.Items.Insert(0, New ListItem("Seleccione ", "-1"))
' ddlAlmacen.SelectedValueExist("-1")
' ddlAlmacen.DataBind()
' If GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()}").Rows.Count > 0 Then
' 'SI ES DEL MISMO SUB PROYECTO SUGIERE EL ALMACEN ASIGNADO AL USUARIO
' If UsuarioActual.CveSubProyecto = DdlSubProyectoDatos.SelectedValue.ToEntero() Then
' ddlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
' Else
' Dim CveAlmacen As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()}").ToEntero()
' ddlAlmacen.SelectedValueExist(CveAlmacen)
' End If
' End If
' End If
' 'SI TIENE CONTRATO NO SE MUEVE
' If Not CveContrato > 0 Then
' DdlAlmacenAsignado.Items.Clear()
' DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()} AND CveTipoAlmacen IN (4,10)")
' DdlAlmacenAsignado.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
' DdlAlmacenAsignado.SelectedValue = "-1"
' DdlAlmacenAsignado.DataBind()
' DdlAlmacenAsignado.SelectedValueExist(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()}").ToString().ToEntero())
' End If
' If CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then
' DdlAlmacenAsignado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue.ToEntero()}")
' DdlAlmacenAsignado.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
' DdlAlmacenAsignado.SelectedValue = "-1"
' DdlAlmacenAsignado.DataBind()
' DdlAlmacenAsignado.SelectedValueExist(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero())
' End If
' Else
' ddlAlmacen.DataSource = Nothing
' ddlAlmacen.DataBind()
' End If
' UpINV.Update()
'End Sub
Private Sub CargaSubProyecto(Optional CveSubProyecto As Integer = -1, Optional FiltraPorProyecto As Boolean = False)
'DdlSubProyecto.Items.Clear()
'DdlSubProyecto.SelectedValue = Nothing
'If DdlProyecto.SelectedValue.ToEntero() > 0 Then
' DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
' 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"})
'End If
'DdlSubProyecto.DataBind()
'DdlSubProyecto.Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
'If FiltraPorProyecto Then
' DdlSubProyecto.Items.Clear()
' Using ObjSubP As New ClsSubProyectos
' If ObjSubP.GetSubProyectos(UsuarioActual.CveEmpresa) Then
' DdlSubProyecto.DataSource = ObjSubP.DtResultados.FiltraParametros(String.Format("CveProyecto = {0}", DdlProyecto.SelectedValue))
' End If
' End Using
' DdlSubProyecto.DataBind()
' DdlSubProyecto.Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
'End If
'If CveSubProyecto > 0 Then DdlSubProyecto.SelectedValueExist(CveSubProyecto)
End Sub
Private Sub CargaEmpresaCRM(CveEmpresaCRM As Integer)
Dim ObjCRM As New ClsCRM
If ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveEmpresaCRM) Then
If ObjCRM.DtResultados.Rows.Count > 0 Then
ViewState("CveCliente") = IIf(ObjCRM.DtResultados.Rows(0)("CveCliente").ToString().ToEntero() > 0, ObjCRM.DtResultados.Rows(0)("CveCliente"), -1)
HdnCveCliente.Value = CveCliente.ToString()
If (CveCliente > 0) Then
CargaCliente(CveCliente)
'DESACTIVA CAMBIO DE CLIENTE
HlCliente.Attributes.Remove("class")
HlCliente.Attributes.Add("class", "Texto disabled")
TxtCodigo.ReadOnly = True
UpCliente.Visible = True
'UpEmpresaCRM.Visible = False
Else
LblEmpresaCRM.Text = ObjCRM.DtResultados.Rows(0)("Empresa").ToString()
LblRFCCRM.Text = ObjCRM.DtResultados.Rows(0)("RFC").ToString()
LblMedioCaptacionCRM.Text = ObjCRM.DtResultados.Rows(0)("MedioCaptacion").ToString()
UPCondicionesPago.Visible = True
trNombreCliente.Visible = False
trsucursalciente.Visible = False
TrDireccion.Visible = False
TrCiudad.Visible = False
TrRFC.Visible = False
TrOP.Visible = False
'trDireccionEnvio.Visible = False
trCRM1.Visible = True
trCRM2.Visible = True
trCRM3.Visible = True
LblTituloPorletCliente.Text = "EMPRESA CRM"
End If
Me.CveVendedorEmpresaCRM = ObjCRM.DtResultados.Rows(0)("CveVendedorAsignado").ToString().ToEntero()
LbAgregar.Enabled = True
'TrAtencionA.Visible = True
TrOC.Visible = True
End If
GvPS.Columns(5).Visible = True
End If
ObjCRM.Dispose()
End Sub
Private Sub CargaCliente(CveCliente As Integer, Optional Estatus As Integer = -1)
If CveCliente <= 0 Then Exit Sub
Dim ObjCliente As New ClsClientes()
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus, TipoCliente:=-1) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
TxtCodigo.Text = ObjCliente.Codigo
LblCliente.Text = String.Format("{1}", CveCliente, ObjCliente.NombreComercial)
ViewState("NombreCliente") = ObjCliente.Nombre
ViewState("RequiereOC") = ObjCliente.RequiereOC
EnviarCorreoCliente = ObjCliente.EnviarFactura
EstatusCliente = ObjCliente.Estatus
Me.PermiteCredito = ObjCliente.PermiteCredito
LnkAgregarCliente.Visible = False
'ClienteEsDistribuidor = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("EsDistribuidor").ToString())
TieneDiasVencidos = Boolean.Parse(ObjCliente.DtResultados.Rows(0)("TieneDiasVencidos").ToString())
DiasVencidosCliente = ObjCliente.DtResultados.Rows(0)("DiasVencidosCliente").ToString().ToEntero()
ClienteCodigoRegimenFiscal = ObjCliente.DtResultados.Rows(0)("CodigoRegimenFiscal").ToString()
ClienteRegimenFiscal = ObjCliente.DtResultados.Rows(0)("RegimenFiscal").ToString()
If EstatusCliente = False And Not DdlTipoComprobante.SelectedValue.Contiene("Cot", "DPe") And (CveVenta <= 0 Or EsCreaApartirDe) Then
Alert("El Cliente seleccionado no esta activo", TipoMensaje.MsgAdvertencia)
BtnEmitirImprimir.Visible = EstatusCliente
TrVistaPrevia.Visible = EstatusCliente
End If
If ViewState("CveDevolucion") IsNot Nothing AndAlso ViewState("NuevaFactura") IsNot Nothing Then
If (CveDevolucion > 0 AndAlso NuevaFactura = 1) Then
BtnEmitirImprimir.Visible = EstatusCliente
TrVistaPrevia.Visible = EstatusCliente
End If
End If
'CUANDO SEA COTIZACION Y SEA COMPUPROVEEDORES (EMPRESA 72) NO DEBE ENVIAR CORREO AL CLIENTE
ViewState("Mail") = If(DdlTipoComprobante.SelectedValue = "Cot", ObjCliente.MailCotizacion, ObjCliente.Mail)
ViewState("MailCC") = ObjCliente.NotificarA
CorreoEntregaAlmacen = ObjCliente.DtResultados(0)("CorreoEntregaAlmacen").ToString
LblDireccion.Text = ObjCliente.Direccion
LblColonia.Text = ObjCliente.Colonia
LblCiudad.Text = ObjCliente.Ciudad
LblEstado.Text = ObjCliente.Estado
LblCP.Text = ObjCliente.CP
LblRFC.Text = ObjCliente.RFC
LblTelefono.Text = ObjCliente.Telefono
LblRetIVA.Text = ObjCliente.RetIVA.ToString().FormatoNumero(5)
LblRetISR.Text = ObjCliente.RetISR.ToString().FormatoNumero(5)
If UsuarioActual.Empresa.MostrarRetISR AndAlso ObjCliente.RetISR > 0 Then
' TrRetISR.Style.Add("display", "none")
TrRetISR.Visible = True
Else
TrRetISR.Visible = False
End If
ViewState("ClienteRetIVA") = ObjCliente.RetIVA / 100
ViewState("ClienteRetISR") = ObjCliente.RetISR / 100
If CveVenta <= 0 OrElse EsCreaApartirDe Then
DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString())
DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty)
ViewState("RetIVAFletes") = ObjCliente.RetieneIVAFletes
If ObjCliente.RetieneIVAFletes Then
TrRetIVA.Style.Add("display", "")
UsuarioActual.Empresa.MostrarRetIVA = True
End If
End If
ViewState("Vendedor") = ObjCliente.Vendedor
ViewState("CodCliente") = ObjCliente.Codigo
ViewState("CvePrecioLista") = ObjCliente.CvePrecioLista
ViewState("CvePrecioListaCliente") = ObjCliente.CvePrecioLista
ViewState("CliNoExt") = ObjCliente.NoExt
ViewState("CliNoInt") = ObjCliente.NoInt
ViewState("CliLocalidad") = If(ObjCliente.Localidad.Trim.Length = 0, ObjCliente.Ciudad.Trim, ObjCliente.Localidad.Trim)
ViewState("CliPais") = ObjCliente.Pais
ImprimeNombreSucursal = ObjCliente.ImprimeNombreSucursal
RegimenFiscalCliente = ObjCliente.DtResultados(0)("CodigoRegimenFiscal").ToString()
RegimenSociedad = ObjCliente.DtResultados(0)("RegimenSociedad").ToString()
TipoPersona = CBool(ObjCliente.DtResultados(0)("TipoPersona"))
CargaUsoCFDI()
'ViewState("NumCtaPago") = ObjCliente.NumCtaPago
ViewState("ClienteDesglosaIEPS") = ObjCliente.DesglosaIEPS
ViewState("CargoUsado") = ObjCliente.CargoUsados
Dim dr As DataRow = Nothing
dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal = 1 And Estatus = 'Activo' AND CveEmpresa = " & UsuarioActual.CveEmpresa)
If dr IsNot Nothing Then
ViewState("MatCalle") = dr("Calle")
ViewState("MatNoExt") = dr("NoExt")
ViewState("MatNoInt") = dr("NoInt")
ViewState("MatColonia") = dr("Colonia")
ViewState("MatLocalidad") = dr("Localidad")
ViewState("MatMunicipio") = dr("Municipio")
ViewState("MatEstado") = dr("Estado")
ViewState("MatPais") = dr("Pais")
ViewState("MatCP") = dr("CP")
End If
If CveCliente = 239903 AndAlso UsuarioActual.CveEmpresa = 119 Then
DdlMetodoPago33.Enabled = False
'ObjCliente.CveMetodoPago = 1 ' PUE, y que no se pueda modificar
Else
DdlMetodoPago33.Enabled = True
End If
Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero()
Me.CveMetodoPago33Cliente = ObjCliente.CveMetodoPago33
Me.CveFormaPago33Cliente = ObjCliente.CveFormaPago33
If (CveVenta <= 0 AndAlso CveCotizacion <= 0) Or EsCreaApartirDe Or NuevaFactura = 1 OrElse ModalidadEdicion Then
DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33)
CambiaMetodoPago33()
DdlFormaPago33.SelectedValueExist(ObjCliente.CveFormaPago33)
DdlUsoCFDI.SelectedValueExist(ObjCliente.CveUsoCFDI)
'SI ES RFC GENERICO NO TIENE OBLIGACIONES FISCALES
If LblRFC.Text.Contiene("XAXX010101000", "XEXX010101000") Then
'S01 Sin efectos fiscales.
DdlUsoCFDI.SelectedValueExist("23")
DdlUsoCFDI.Enabled = False
RegimenFiscalCliente = "616"
ClienteCodigoRegimenFiscal = "616"
End If
End If
PlazoCobranza = ObjCliente.PlazoCobranza
PlazoCobranzaRemision = ObjCliente.PlazoCobranzaRemision
'funcionalidad EnviarSMSTimbrado
If CveVenta <= 0 And UsuarioActual.Empresa.Funcionalidad(152) <> "" And DdlTipoComprobante.SelectedValue = "Ing" Then
If ObjCliente.CobranzaTelefono <> "" Then
LblMensaje.Text = $"Se enviará mensaje SMS a {ObjCliente.CobranzaTelefono}"
Else
LblMensaje.Text = $"El Cliente no tiene teléfono para envío SMS "
End If
LblMensaje.Visible = True
End If
'If Not ObjCliente.RFC = "XAXX010101000" Then
' TxtNumCtaPago.Text = ObjCliente.NumCtaPago
'End If
'Complementos
'COMERCIO EXTERIOR
ViewState("AplicaComercioExterior") = ObjCliente.AplicaComercioExterior
ViewState("CveTipoOperacion") = ObjCliente.CveTipoOperacion
ViewState("CvePedimento") = ObjCliente.CvePedimento
ViewState("CveIncoterm") = ObjCliente.CveIncoterm
ViewState("AplicaFEMSA") = ObjCliente.AplicaFEMSA
ViewState("AplicaDetallista") = ObjCliente.AplicaDetallista
ViewState("AplicaFord") = ObjCliente.AplicaFord
If ObjCliente.DtResultados(0)("CveVendedor").ToString().ToEntero() > 0 Then
CveVendedorCliente = ObjCliente.DtResultados(0)("CveVendedor").ToString().ToEntero()
End If
UpFacturar.Update()
UpnTools.Update()
If Not CveVenta > 0 Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If UsuarioActual.TienePermisoProceso(152) Then
DdlSubProyectoDatos.SelectedValueExist(UsuarioActual.CveSubProyecto)
DdlSubProyectoDatos.Enabled = False
Else
DdlSubProyectoDatos.SelectedValueExist(UsuarioActual.CveSubProyecto) ' DdlSubProyectoDatos.SelectedValueExist(ObjCliente.CveSubProyecto)
End If
'RECARGA LOS VALORES DE LA SUCURSAL
CambiaSucursal()
UpParametros.Update()
End If
End If
DdlSucursalCliente.Items.Clear()
If ObjCliente.GetSucursales(CveCliente) Then
DdlSucursalCliente.DataSource = ObjCliente.DtResultados
If ObjCliente.DtResultados.Rows.Count > 0 Then
trsucursalciente.Visible = True
Else
trsucursalciente.Visible = False
End If
Else
trsucursalciente.Visible = False
DdlSucursalCliente.DataSource = Nothing
End If
DdlSucursalCliente.Items.Insert(0, New ListItem("Matriz", "-1"))
DdlSucursalCliente.DataBind()
'SI UTILIZA EL RFC GENERICO PERMITE FACTURAR SUCURSAL
If (Not UsuarioActual.Empresa.Funcionalidad(558) = "1") AndAlso (CveVenta <= 0 OrElse NuevaFactura = 1) AndAlso LblRFC.Text.Trim() = "XAXX010101000" Then
HabilitarFacturacionSucursal()
End If
'CargaFolios()
If ObjCliente.GetClienteImpuestosLocales(CveCliente) AndAlso CveVenta <= 0 Then
'se cargan impuestos locales
Dim DtClienteImpuesto As DataTable = ObjCliente.DtResultados.FiltraParametros("Seleccionado = 1", "Orden")
If DtClienteImpuesto IsNot Nothing AndAlso DtClienteImpuesto.Rows.Count > 0 Then
' If TmpDTImpuestos Is Nothing Then CreaDTImpuestos() Else TmpDTImpuestos.Rows.Clear()
TmpDTImpuestos = DtClienteImpuesto
GvImpuestosLocales2.DataSource = TmpDTImpuestos
GvImpuestosLocales2.DataBind()
If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then
TrOtros.Visible = True
GvImpuestosLocales2.Visible = True
TrOtros.Style.Add("display", "")
Else
TrOtros.Visible = False
GvImpuestosLocales2.Visible = False
End If
DtClienteImpuesto.Dispose()
End If
UpImpuestos.Update()
End If
If DdlTipoComprobante.SelectedValue.Contiene("Cot") Then
'TrAtencionA.Visible = True
TrDireccion.Visible = False
TrCiudad.Visible = False
TrRFC.Visible = False
'tdTelefonoGen.Visible = False
'tdTxtTelefonoGen.Visible = False
ElseIf ObjCliente.RFC = "XAXX010101000" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ret") Then
'TrAtencionA.Visible = True
TrDireccion.Visible = False
TrCiudad.Visible = False
TrRFC.Visible = False
'tdTelefonoGen.Visible = True
'tdTxtTelefonoGen.Visible = True
Else
'TrAtencionA.Visible = False
TrDireccion.Visible = True
TrCiudad.Visible = True
TrRFC.Visible = True
'tdTelefonoGen.Visible = False
'tdTxtTelefonoGen.Visible = False
'TxtAtencionA.Text = ""
'TxtTelefonoGenerico.Text = ""
End If
'TrAtencionA.Visible = True
'tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
'tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot")
LbAgregar.Enabled = True
If UsuarioActual.CveEmpresa.Contiene(72, 80, 1, 119) Then
BtnEmitirImprimir.OnClientClick = $"ValidaGuardar({ If(ImprimeNombreSucursal = True, 1, 0)});"
BtnEmitirImprimir.Attributes.Add("data-toggle", "confirmation")
BtnEmitirImprimir.Attributes.Add("data-popout", "true")
BtnEmitirImprimir.Attributes.Add("data-original-title", "confirmar")
BtnEmitirImprimir.Attributes.Add("data-btn-ok-label", "Guardar")
BtnEmitirImprimir.Attributes.Add("data-html", "true")
End If
'VALIDA ESTATUS CLIENTE - SOLO SE PUEDE USAR EL CLIENTE PARA COTIZAR EN CASO DE ESTAR INACTIVO
If DdlTipoComprobante.SelectedValue.Contiene("Cot", "DPe") Or TipoContrato >= 0 Then 'SI VIENE DE PEDIDO DE AF DESDE CONTRATO NO BLOQUEA CUANDO EL CLIENTE ESTA INACTIVO
BtnEmitirImprimir.Visible = True
TrVistaPrevia.Visible = True
'Else
' BtnEmitirImprimir.Visible = EstatusCliente
' TrVistaPrevia.Visible = EstatusCliente
End If
TrVistaPrevia.Visible = True
' si es empresa acumuladores
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
CargaPorcentajeMarcas()
End If
'CargaFacturasARelacionar()
UpFacturar.Update()
UpEstatus.Update()
UpPS.Update()
UpParametros.Update()
UPCondicionesPago.Update()
UpCliente.Update()
UpnTools.Update()
Else
Alert("Ocurrió un error al cargar los datos del cliente. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If
End If
ObjCliente.Dispose()
BloqueaCondiconesPago()
DeshabilitarAplicarNotaDeCredito(LblRFC.Text)
Dim CveVentaRef As Integer = -1
If Me.CveVenta > 0 AndAlso Not EsCreaApartirDe Then
CveVentaRef = Me.CveVenta
End If
CargaRestriccionesCreditoCliente(True, CveVentaRef)
If CveVenta <= 0 Then
'CalculaLineasAdicionales()
HabilitaRemisionPublicoGeneral = 0
HabilitarRemisionesPublicoGeneral()
End If
'If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then
' Using ObjVentas As New ClsVentas
' If ObjVentas.GetLineasAdicionales(-1, CveCliente, -1, -1, DdlMoneda.SelectedValue.ToEntero(), MinFecha, MaxFecha, 0, UsuarioActual.CveEmpresa) Then
' If ObjVentas.DtResultados.Rows.Count > 0 Then
' TrLineaAdicional.Visible = True
' End If
' End If
' End Using
'End If
End Sub
Private Sub HabilitarRemisionesPublicoGeneral()
If UsuarioActual.Empresa.Funcionalidad(381).Trim() <> "" Then
'SI ESTA BLOQUEADO POR AUTORIZACION, HABILITAR LA OPCION DE REMISION PARA PUBLICO EN GENERAL
If UsuarioActual.Empresa.Funcionalidad(381).Trim() = CveCliente.ToString() Then
Dim DeshabilitarAutorizacion As Boolean = CBool(GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("DeshabilitaAutorizacion"))
'SI ESTA BLOQUEADO POR AUTORZACION O QUE TENGA LA OPCION DE AUTORIZACIONES Y NO SEA DEL MODULO DE COTIZACIONES
If (DdlTipoComprobante.SelectedValue.Contiene("PA") OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso DdlTipoComprobante.Items.FindByValue("PA") IsNot Nothing AndAlso Not IfNull(Request("Op"), "").ToString() = "Cot")) AndAlso DeshabilitarAutorizacion Then
If DdlTipoComprobante.Items.FindByValue("Rem") Is Nothing Then
DdlTipoComprobante.Items.Insert(0, New ListItem("Remisión", "Rem"))
End If
DdlTipoComprobante.SelectedValueExist("Rem")
HabilitaRemisionPublicoGeneral = 1
End If
'SI TUVO HABILITADO EL BLOQUEO POR AUTORIZACION PERO DESPUES SE CAMBIO MANUAL A REMISION
If DdlTipoComprobante.SelectedValue.Contiene("Rem") AndAlso TieneBloqueoPorAutorizacion = 1 Then
HabilitaRemisionPublicoGeneral = 1
End If
'SI TIENE LA HABILITACION DE REMISION ACTIVA Y LA SUCURSAL NO LO PERMITE
If Not DeshabilitarAutorizacion AndAlso HabilitaRemisionPublicoGeneral = 1 Then
HabilitaRemisionPublicoGeneral = 0
DdlTipoComprobante.SelectedValueExist("PA")
If DdlTipoComprobante.Items.FindByValue("Rem") IsNot Nothing Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
End If
End If
UpParametros.Update()
End If
Else
HabilitaRemisionPublicoGeneral = 0
End If
End Sub
Private Function ValidaImportePublicoGeneral() As Boolean
Dim retorno As Boolean = False
If DdlTipoComprobante.SelectedValue = "Rem" AndAlso HabilitaRemisionPublicoGeneral = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(381).Trim() = CveCliente.ToString() Then
Dim Total As Decimal = TxtTotal.Text.ToDecimal()
If DdlMoneda.SelectedValue = "1" Then
If Total <= 5000D Then
retorno = True
Else
Alert("No puede generar una remisión con un valor mayor a 5,000 MXN. Debe cambiar el tipo de documento a 'Autorización'", TipoMensaje.MsgAdvertencia)
End If
End If
If DdlMoneda.SelectedValue = "2" Then
If TxtTipoCambio.Text.ToDecimal() > 0 Then
Dim TotalPesos As Decimal = (Total * TxtTipoCambio.Text.ToDecimal())
If TotalPesos <= 5000D Then
retorno = True
Else
Alert($"No puede generar una remisión con un valor mayor a {(5000 / TxtTipoCambio.Text.ToDecimal()).RoundSQL(2)} USD. Debe cambiar el tipo de documento a 'Autorización'", TipoMensaje.MsgAdvertencia)
End If
Else
Alert("No se ha especificado un tipo de cambio", TipoMensaje.MsgAdvertencia)
End If
End If
Else
retorno = True
End If
Return retorno
End Function
Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1)
Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595)
'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO
If (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("1", "2")) AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then
'GENERAR UNA AUTORIZACIÓN SI EL CLIENTE NO PERMITE CREDITO
If UsuarioActual.Empresa.Funcionalidad(595) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(268) Then
'SI LLEGÓ POR LA OPCIÓN DE COTIZACIÓN NO DEBE DE RESTRINGUIR
If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
DdlTipoComprobante.SelectedValue = "Cot"
BtnGenerarRemision.Visible = False
Else
DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
DdlTipoComprobante.SelectedValue = "PA"
TieneBloqueoPorAutorizacion = 1
End If
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
If Not UsuarioActual.TienePermisoProceso(325) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
End If
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
BtnsFacturar.Visible = False
End If
UPCondicionesPago.Update()
'CARGAR CREDITO DISPONIBLE AL GENERAR UNA FACTURA
End If
'If ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta <= 0) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) AndAlso PermiteCredito Then
' 'FUNCIONALIDAD 702 - NO VERIFICAR LIMITE DE CRÉDITO Y CANDADOS DE VENTA
' If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then
' Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero())
' If CreditoDispo > 0 Then
' TrCreditoDisponible.Visible = True
' LblCreditoDisponible.Text = CreditoDispo.FormatoNumero
' If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%"
' If Not UsuarioActual.TienePermisoProceso(268) AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) AndAlso (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) Then
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion > 0 Then
' 'si la cotización no debe de existir este canddado
' If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
' 'RBLPago.SelectedValue = "2"
' 'RBLPago.Items(0).Enabled = False
' UPCondicionesPago.Update()
' If Not EsCreaApartirDe AndAlso (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
' DdlTipoComprobante.SelectedValueExist("Cot")
' Else
' If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
' DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
' DdlTipoComprobante.SelectedValue = "PA"
' TieneBloqueoPorAutorizacion = 1
' End If
' End If
' 'si llegó por la opción de cotización no debe de restringuir
' If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValue = "Cot"
' 'quito remisión y factura
' If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
' If Not UsuarioActual.TienePermisoProceso(325) Then
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
' End If
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
' End If
' 'SI ES AUTORIZACION DEBE PERMITIR GENERARLA
' If (Not DdlTipoComprobante.SelectedValue.Contiene("PA")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
' BtnEmitirImprimir.Visible = False
' BtnsFacturar.Visible = False
' LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
' BtnGenerarRemision.Visible = False
' 'LnkPedido2SinFacturar.Visible = False
' LnkCotizaciones.Visible = False
' LnkOCs.Visible = False
' End If
' If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
' Dim Autorizacion As Integer = 0
' Dim ObjVentas As New ClsVentas
' If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then
' Dim RowAutorizacion As DataRow = Nothing
' 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
' If TieneDiasVencidos Then
' RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
' Else
' RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
' End If
' If RowAutorizacion IsNot Nothing Then
' Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
' End If
' End If
' ObjVentas.Dispose()
' 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
' If Autorizacion > 0 Then
' BtnsFacturar.Visible = True
' End If
' End If
' Else
' ' el cliente tiene crédito disponible, no tiene bloqueo
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA"))
' Dim EsCotizacion As Boolean = False
' If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
' EsCotizacion = True
' End If
' If UsuarioActual.TienePermisoProceso(199) Then DdlTipoComprobante.SelectedValueExistInsert("Rem", "Remisión") ' puede remisionar
' If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar
' DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento)
' If EsCotizacion Then
' DdlTipoComprobante.SelectedValueExistInsert("Cot", "Cotización")
' End If
' If EsCotizacion AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
' Dim Autorizacion As Integer = 0
' Dim ObjVentas As New ClsVentas
' If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then
' Dim RowAutorizacion As DataRow = Nothing
' 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
' If TieneDiasVencidos Then
' RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
' Else
' RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC")
' End If
' If RowAutorizacion IsNot Nothing Then
' Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
' End If
' End If
' ObjVentas.Dispose()
' 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO
' If Autorizacion > 0 Then
' BtnsFacturar.Visible = True
' End If
' End If
' End If
' End If
' Else
' 'GENERAR AUTORIZACION SI TIENE EXCEDIO EL LIMITE DE CREDITO
' Select Case ValorAutorizacion
' Case "1" 'CREAR DOCUMENTO DE AUTORIZACION PA
' If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") AndAlso Not (UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
' 'VERIFICAR CANDADOS DE VENTA, REMISIONES SIN FACTURAR, FACTURAS QUE NO TENGAN VENCIDAS
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion > 0 Then
' 'If Opcion = 1 Then
' ' BtnEmitirImprimir.Visible = False
' ' BtnsFacturar.Visible = False
' 'End If
' If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
' Else
' If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia)
' End If
' UPCondicionesPago.Update()
' DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
' DdlTipoComprobante.SelectedValue = "PA"
' TieneBloqueoPorAutorizacion = 1
' 'si llegó por la opción de cotización no debe de restringuir
' If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValue = "Cot"
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
' If Not UsuarioActual.TienePermisoProceso(325) Then
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
' End If
' DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
' BtnsFacturar.Visible = False
' LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
' BtnGenerarRemision.Visible = False
' 'LnkPedido2SinFacturar.Visible = False
' LnkCotizaciones.Visible = False
' LnkOCs.Visible = False
' Else
' If DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 Then
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion > 0 Then
' BtnsFacturar.Visible = False
' BtnGenerarRemision.Visible = False
' Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
' End If
' End If
' End If
' Case "2" 'Autorizacion desde una solicitud del catalogo de autorizaciones
' 'RMF. validacion temporal
' 'verifica si tiene autorizaciones de Nota de crédito autorizadas
' Dim ObjVentas As New ClsVentas
' If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, -1, "Ing", CveEstatus:=1) Then
' Dim RowAutorizacion As DataRow = ObjVentas.DtResultados.FiltroPrimero($"CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="TipoAutorizacion")
' If RowAutorizacion IsNot Nothing Then
' DdlTipoComprobante.SelectedValueExistInsert("Egs", "Egresos")
' End If
' End If
' ObjVentas.Dispose()
' Case Else 'SI NO TIENE NINGUN TIPO DE AUTORIZACION CONFIGURADO
' 'RMF. codigo temporal para pruebas
' If Alertas AndAlso UsuarioActual.CveEmpresa = 140 Then
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion > 0 Then
' LnkSolicitarCredito.Visible = True
' Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
' End If
' Else
' 'VERIFICAR CANDADOS DE VENTA
' If DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 Then
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion > 0 Then
' BtnsFacturar.Visible = False
' BtnGenerarRemision.Visible = False
' Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
' End If
' End If
' End If
' End Select
' End If
' End If
'Else
'End If
'Puede hacer pedido
If CveVenta <= 0 Then
If Not UsuarioActual.TienePermisoProceso(177) Then
If DdlTipoComprobante.Items.FindByValue("Pd2") IsNot Nothing Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2"))
End If
End If
End If
End Sub
Private Sub CargaClienteSucursal(CveClienteSuc As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing)
Me.ClienteSucursal = Nothing
Me.FacturarSucursal = False
LtlTitleRFCSucursal.Text = ""
LtlRFCSucursal.Text = ""
Dim ObjCliente As New ClsClientes
If CveClienteSuc > 0 Then
If ObjCliente.GetSucursales(CveCliente, CveClienteSuc) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
Dim Correo As String = ObjCliente.DtResultados.Rows(0)("Correo").ToString()
If Correo.Trim.Length > 0 Then
ViewState("Mail") = Correo
End If
LblDireccion.Text = ObjCliente.DtResultados.Rows(0)("Direccion").ToString()
LblColonia.Text = ObjCliente.DtResultados.Rows(0)("Colonia").ToString()
LblCiudad.Text = ObjCliente.DtResultados.Rows(0)("Ciudad").ToString()
LblEstado.Text = ObjCliente.DtResultados.Rows(0)("Estado").ToString()
'TxtNumCtaPago.Text = ObjCliente.DtResultados.Rows(0)("NumCtaPago").ToString()
LblTelefono.Text = ObjCliente.DtResultados.Rows(0)("Telefono").ToString()
ViewState("CliLocalidad") = ObjCliente.DtResultados.Rows(0)("Localidad").ToString()
ViewState("CliPais") = ObjCliente.DtResultados.Rows(0)("Pais").ToString()
ViewState("CliNoExt") = ObjCliente.DtResultados.Rows(0)("NoExt").ToString()
ViewState("CliNoInt") = ObjCliente.DtResultados.Rows(0)("NoInt").ToString()
Me.CveVendedorClienteSucursal = ObjCliente.DtResultados.Rows(0)("CveVendedor").ToString().ToEntero()
ViewState("CveClienteSucursal") = ObjCliente.DtResultados(0)("CveClienteSucursal").ToString()
ViewState("CliCorreoCot") = ObjCliente.DtResultados.Rows(0)("CorreoCotizacion").ToString()
'If ObjCliente.DtResultados.Rows(0)("Estatus").ToString() <> "Activo" Then
' Alert("La Sucursal/Departamento del cliente se encuentra inactivo", TipoMensaje.MsgAdvertencia)
'Else
' Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero(), ObjVentas)
' TrCreditoDisponible.Visible = True
' LblCreditoDisponible.Text = CreditoDispo.FormatoNumero
' UPPCreditoDisponible.Update()
' UpParametros.Update()
'End If
'SI EL CLIENTE TIENE RFC GENERICO Y LA SUCURSAL TIENE RFC DEBE FACTURAR LA SUCURSAL
If (Not UsuarioActual.Empresa.Funcionalidad(558) = "1") AndAlso LblRFC.Text.Trim() = "XAXX010101000" AndAlso Not String.IsNullOrEmpty(ObjCliente.DtResultados.Rows(0)("RFC").ToString()) Then
Me.FacturarSucursal = True
LtlTitleRFCSucursal.Text = "RFC:"
LtlRFCSucursal.Text = ObjCliente.DtResultados.Rows(0)("RFC").ToString()
Me.ClienteSucursal = New Modelos.SucursalModel
Me.ClienteSucursal.Nombre = ObjCliente.DtResultados.Rows(0)("SucursalCliente").ToString()
Me.ClienteSucursal.RFC = ObjCliente.DtResultados.Rows(0)("RFC").ToString()
Me.ClienteSucursal.NoExt = CliNoExt
Me.ClienteSucursal.NoInt = CliNoInt
Me.ClienteSucursal.Localidad = CliLocalidad
Me.ClienteSucursal.Direccion = LblDireccion.Text
Me.ClienteSucursal.Colonia = LblColonia.Text
Me.ClienteSucursal.Municipio = LblCiudad.Text
Me.ClienteSucursal.Estado = LblEstado.Text
Me.ClienteSucursal.CP = LblCP.Text
Me.ClienteSucursal.Pais = CliPais
Me.ClienteSucursal.CorreoSucursal = CliCorreoCot.ToString()
Me.ClienteSucursal.TelefonoSucursal = LblTelefono.Text
Me.ClienteSucursal.Sucursal = If(DdlSucursalCliente.SelectedValue.ToEntero() > 0, DdlSucursalCliente.SelectedItem.Text, "")
Me.ClienteSucursal.ImprimeNombreSucursal = ImprimeNombreSucursal.ToString()
End If
If CveVenta <= 0 Then
'CveMetodoPagoCliente = ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString().ToEntero()
DdlMetodoPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago33").ToString())
DdlMetodoPago33_SelectedIndexChanged(DdlMetodoPago33, EventArgs.Empty)
DdlFormaPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveFormaPago33").ToString())
DdlUsoCFDI.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveUsoCFDI").ToString())
'SI ES RFC GENERICO NO TIENE OBLIGACIONES FISCALES
If LblRFC.Text.Contiene("XAXX010101000", "XEXX010101000") Then
'S01 Sin efectos fiscales.
DdlUsoCFDI.SelectedValueExist("23")
DdlUsoCFDI.Enabled = False
RegimenFiscalCliente = "616"
ClienteCodigoRegimenFiscal = "616"
End If
End If
End If
Else
Alert("No se pudieron cargar los datos de la sucursal", TipoMensaje.MsgAdvertencia)
End If
Else
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, TipoCliente:=-1) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
ViewState("Mail") = If(DdlTipoComprobante.SelectedValue = "Cot", ObjCliente.MailCotizacion, ObjCliente.Mail)
LblDireccion.Text = ObjCliente.Direccion
LblColonia.Text = ObjCliente.Colonia
LblCiudad.Text = ObjCliente.Ciudad
LblEstado.Text = ObjCliente.Estado
LblCP.Text = ObjCliente.CP
LblTelefono.Text = ObjCliente.Telefono
Me.CveVendedorClienteSucursal = -1
Me.CveVendedorCliente = ObjCliente.DtResultados.Rows(0)("CveVendedor").ToString().ToEntero()
ViewState("CliNoExt") = ObjCliente.NoExt
ViewState("CliNoInt") = ObjCliente.NoInt
PlazoCobranza = ObjCliente.PlazoCobranza
Dim CveCotizacion As Integer = IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero()
If CveVenta <= 0 AndAlso CveCotizacion <= 0 Then
'CveMetodoPagoCliente = ObjCliente.CveMetodoPago
DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33)
DdlMetodoPago33_SelectedIndexChanged(DdlMetodoPago33, EventArgs.Empty)
DdlFormaPago33.SelectedValueExist(ObjCliente.CveFormaPago33)
DdlUsoCFDI.SelectedValueExist(ObjCliente.CveUsoCFDI)
'SI ES RFC GENERICO NO TIENE OBLIGACIONES FISCALES
If LblRFC.Text.Contiene("XAXX010101000", "XEXX010101000") Then
'S01 Sin efectos fiscales.
DdlUsoCFDI.SelectedValueExist("23")
DdlUsoCFDI.Enabled = False
RegimenFiscalCliente = "616"
ClienteCodigoRegimenFiscal = "616"
End If
End If
End If
End If
End If
''SI LA SUCURSAL DEL CLIENTE NO TIENE VENDEDOR SELECCIONAMOS EL DEL USUARIO
'If Not -1 > 0 Then
' DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString())
'End If
ObjCliente.Dispose()
UpEstatus.Update()
UPCondicionesPago.Update()
UpCliente.Update()
'UpEmitirTransitorio.Update()
End Sub
Private Function CargaCreditoDisponible(tCveCliente As Integer, tCveSucursalCliente As Integer, Optional ByRef ObjVentas As ClsVentas = Nothing) As Decimal
Dim Retorno As Decimal = 0
Dim ObjVentasAplciar As ClsVentas = Nothing
If ObjVentas IsNot Nothing Then
ObjVentasAplciar = ObjVentas
Else
ObjVentasAplciar = New ClsVentas
End If
If ObjVentasAplciar.ObtenerCreditoRestante(tCveCliente, tCveSucursalCliente) Then
If ObjVentasAplciar.DtResultados.Rows.Count > 0 Then
If tCveSucursalCliente > 0 Then
Dim LimiteRestanteSucursal As Decimal = ObjVentasAplciar.DtResultados(0)("LimiteRestanteSucursal").ToString().ToDecimal
Dim PorcentajeSaldoSucursal As Decimal = ObjVentasAplciar.DtResultados(0)("PorcentajeSaldoSucursal").ToString().ToDecimal
Dim LimiteRestanteCliente As Decimal = ObjVentasAplciar.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal
Dim PorcentajeSaldoCliente As Decimal = ObjVentasAplciar.DtResultados(0)("PorcentajeSaldoCliente").ToString().ToDecimal
'SI EL LIMITE DE LA SUCURSAL ES MAYOR AL DEL CLIENTE DEBE LIMITAR AL DEL CLIENTE
If LimiteRestanteSucursal > LimiteRestanteCliente Then
Retorno = LimiteRestanteCliente
PorcentajeCredito = PorcentajeSaldoCliente
ElseIf LimiteRestanteSucursal < LimiteRestanteCliente Then
Retorno = LimiteRestanteSucursal
PorcentajeCredito = PorcentajeSaldoSucursal
ElseIf LimiteRestanteSucursal = LimiteRestanteCliente Then
Retorno = LimiteRestanteSucursal
PorcentajeCredito = PorcentajeSaldoSucursal
End If
Else
Retorno = ObjVentasAplciar.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal
PorcentajeCredito = ObjVentasAplciar.DtResultados(0)("PorcentajeSaldoCliente").ToString().ToDecimal
End If
End If
End If
If ObjVentas Is Nothing Then
ObjVentasAplciar.Dispose()
End If
Return Retorno
End Function
Private Sub CargaDdlSubProyectos()
Dim dtt As New DataTable
dtt = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
DdlSubProyectoDatos.DataSource = dtt.FiltraParametros("EsSucursal = True ")
DdlSubProyectoDatos.DataBind()
'DdlSubProyectoCobranza.DataSource = dtt.FiltraParametros("EsSucursal = True ")
'DdlSubProyectoCobranza.DataBind()
'DdlSubProyectoEjecucion.DataSource = dtt.FiltraParametros("EsSucursal = True ")
'DdlSubProyectoEjecucion.DataBind()
'DdlSubProyectoFiltroAF.DataSource = dtt
'DdlSubProyectoFiltroAF.DataBind()
'DdlSubProyectoFiltroAF.Items.Insert(0, New ListItem("Todos", "-1"))
dtt.Dispose()
End Sub
Private Sub CargaClasificaciones()
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=1).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion")
Else
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("UsoClasificacion IN (1,3) and Estado = 1", Orderby:="Clasificacion")
End If
'DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
DdlClasificacion.DataBind()
End Sub
Private Sub CargaPS(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost, Optional AplicaParaVenta As Boolean = True)
Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1")
If Not UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1" Then
Objeto.ddl.Items.Clear()
'Objeto.ddl.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1)
Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=If(AplicaParaVenta, 1, -1))
Objeto.ddl.DataBind()
Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
Else
If Me.CveVenta > 0 Then
DdlSubProyectoDatos.SelectedValueExist(CveSubProyectoVenta)
End If
Dim cvesubproyecto As String = DdlSubProyectoDatos.SelectedValue
If UsuarioActual.Empresa.Funcionalidad(558) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
'cuando es empresa llantera (558) o cuando es empresa acumuladores
cvesubproyecto = "-1"
End If
Objeto.Attributes.Add("data-cvesubproyecto", cvesubproyecto)
Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString())
Objeto.ddlWS.Attributes.Add("data-Estatus", "1")
If AplicaParaVenta Then
Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1")
End If
End If
End Sub
Private Sub CargaTiposVenta()
RBLTipoVenta.DataSource = GlobalDTTipoVenta().FiltraParametros("Estatus = 'True' ")
RBLTipoVenta.DataBind()
RegistraScript("$('#DvModalTipoVenta').modal({ backdrop: 'static', keyboard: false });")
End Sub
Private Sub CargaProcedimientos()
DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
DdlMedico.DataBind()
DdlMedicoModal.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
DdlMedicoModal.DataBind()
End Sub
Private Sub CargaAgentes()
DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
DdlProcedimiento.DataBind()
DdlProcedimientoModal.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
DdlProcedimientoModal.DataBind()
End Sub
Private Sub CargaPSRemision(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost)
Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1")
If Not UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1" Then
Objeto.ddl.Items.Clear()
'Objeto.ddl.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1)
Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1)
Objeto.ddl.DataBind()
Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
Else
Dim cvesubproyecto As String = "-1"
Objeto.Attributes.Add("data-cvesubproyecto", cvesubproyecto)
Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString())
Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
Objeto.ddlWS.Attributes.Add("data-Estatus", "1")
Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1")
End If
End Sub
#End Region
#Region "G R I D V I E W S"
Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPS.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("id") = e.Row.RowIndex.ToString()
If e.Row.RowIndex = 0 Then
End If
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
'MODO EDICION
If UsuarioActual.Empresa.UsaInventarios Then
e.Row.FCDropDownList("DdlUnidadMedida").DataSource = GlobalDTProductosServiciosEquivalencias(e.Row.DBCampo("CvePS").ToEntero(), -1, UsuarioActual.CveEmpresa)
Else
e.Row.FCDropDownList("DdlUnidadMedida").DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
End If
e.Row.FCDropDownList("DdlUnidadMedida").DataBind()
e.Row.FCDropDownList("DdlUnidadMedida").SelectedValueExist(e.Row.DBCampo("CveUM"))
e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=1)
e.Row.FCDropDownList("DdlClasificacion").DataBind()
e.Row.FCDropDownList("DdlClasificacion").SelectedValue = e.Row.DBCampo("CveClasificacion")
CargaPS(e.Row.FCDropDownList("DdlClasificacion").SelectedValue.ToEntero(), e.Row.FCDropDownLost("DdlPS"))
e.Row.FCDropDownLost("DdlPS").SelectedText = e.Row.DBCampo("PS")
e.Row.FCDropDownLost("DdlPS").SelectedValue = e.Row.DBCampo("CvePS")
If e.Row.DBCampo("CveSubProyecto") = "-1" Then
'cargo todos las opciones para
'e.Row.FCDropDownList("DdlProyecto").DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1)
'e.Row.FCDropDownList("DdlProyecto").DataBind()
'e.Row.FCDropDownList("DdlProyecto").Items.Insert(0, New ListItem("Sin Proyecto Asignado", "-1"))
'e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
'e.Row.FCDropDownList("DdlSubProyecto").DataBind()
'e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
Else
'Dim dr As DataRow = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, e.Row.DBCampo("CveSubProyecto").ToEntero(), 1).FiltroPrimero("")
'If dr IsNot Nothing Then
' e.Row.FCDropDownList("DdlProyecto").DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1)
' e.Row.FCDropDownList("DdlProyecto").DataBind()
' e.Row.FCDropDownList("DdlProyecto").SelectedValue = dr("CveProyecto").ToString()
' e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, dr("CveProyecto").ToString().ToEntero(), UsuarioActual.CveEmpresa, -1, 1)
' e.Row.FCDropDownList("DdlSubProyecto").DataBind()
' e.Row.FCDropDownList("DdlSubProyecto").SelectedValueExist(e.Row.DBCampo("CveSubProyecto"))
'End If
End If
If UsuarioActual.TienePermisoProceso(68) Then
e.Row.FCTextBox("TxtPrecio").Enabled = False
e.Row.FCTextBox("TxtDescuento").Enabled = False
End If
If Not EsCreaApartirDe Then
'Si es una devolucion
If NuevaFactura = 0 Then
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False
e.Row.FCDropDownList("DdlClasificacion").Enabled = False
e.Row.FCDropDownLost("DdlPS").Enabled = False
'e.Row.FCDropDownList("DdlProyecto").Enabled = False
'e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
e.Row.FCTextBox("TxtPrecio").Enabled = False
ElseIf NuevaFactura = 1 Or CveContrato > 0 Then
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False
e.Row.FCDropDownList("DdlClasificacion").Enabled = False
e.Row.FCDropDownLost("DdlPS").Enabled = False
e.Row.FCTextBox("TxtCantidad").Enabled = False
e.Row.FCTextBox("TxtPrecio").Enabled = False
e.Row.FCTextBox("TxtDescuento").Enabled = False
If TieneAlmacen Then e.Row.FCLinkButton("imgD").Visible = False
If UsuarioActual.TienePermisoProceso(222) Then
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = True
e.Row.FCDropDownList("DdlClasificacion").Enabled = True
e.Row.FCDropDownLost("DdlPS").Enabled = True
e.Row.FCTextBox("TxtCantidad").Enabled = True
e.Row.FCTextBox("TxtPrecio").Enabled = True
e.Row.FCTextBox("TxtDescuento").Enabled = True
End If
End If
End If
'Si es facturacion de OC o Contrato
If CveContrato > 0 AndAlso Not CveVenta > 0 AndAlso Not CveCicloComercial > 0 Then
e.Row.FCLinkButton("imgClone").Visible = False
e.Row.FCTextBox("TxtOrden").Visible = True
e.Row.FCTextBox("TxtCantidad").Enabled = False
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False
e.Row.FCDropDownList("DdlClasificacion").Enabled = False
e.Row.FCDropDownLost("DdlPS").Enabled = False
'e.Row.FCDropDownList("DdlProyecto").Enabled = False
'e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
e.Row.FCTextBox("TxtPrecio").Enabled = False
End If
If CveContrato > 0 AndAlso CveContratoTipo = 33 Then
e.Row.FCTextBox("TxtCantidad").Enabled = True
e.Row.FCTextBox("TxtPrecio").Enabled = True
End If
If DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 Then
e.Row.FCLinkButton("imgClone").Visible = False
e.Row.FCTextBox("TxtOrden").Visible = True
e.Row.FCTextBox("TxtCantidad").Enabled = False
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False
e.Row.FCDropDownList("DdlClasificacion").Enabled = False
' e.Row.FCDropDownList("DdlProyecto").Enabled = False
'e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
e.Row.FCLiteral("LtlPSEdit").Visible = True
e.Row.FCDropDownLost("DdlPS").Visible = False
e.Row.FCDropDownLost("DdlPS").Enabled = False
e.Row.FCTextBox("TxtPrecio").Enabled = True
End If
If CveCicloComercial > 0 Then
e.Row.FCTextBox("TxtPrecio").Enabled = True
End If
'CUANDO SE QUIERE FACTURAR UNA REMISIÓN NO PERMITE EDITAR SU PRECIO
If DtRemisionesPS IsNot Nothing AndAlso DtRemisionesPS.Rows.Count > 0 AndAlso (e.Row.DBCampo("CveVentaDetalle").ToEntero() > 0 Or e.Row.DBCampo("CveVentaDetalleRemision").ToEntero() > 0) Then
e.Row.FCTextBox("TxtPrecio").Enabled = False
End If
'PERMISO EDITAR REM
If e.Row.DBCampo("TipoDocto") = "Rem" And ModalidadEdicion Then
'LO PERMITIDO MODIFICAR
e.Row.FCTextBox("TxtPrecio").Enabled = True
e.Row.FCTextBox("TxtObsPS").Enabled = True
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onblur", $"ValidarCantidadMenor(this,{e.Row.DBCampo("CantidadInventario").ToDouble})")
'LO NO PERMITIDO MODIFICAR
e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False
If UsuarioActual.CveEmpresa = 119 Then
e.Row.FCTextBox("TxtCantidad").Enabled = False
End If
'cuando ya tiene una salida, no se puede cambiar el producto
If e.Row.DBCampo("CantidadInventario").ToDouble > 0 Then
e.Row.FCDropDownList("DdlClasificacion").Enabled = False
e.Row.FCDropDownLost("DdlPS").Enabled = False
e.Row.FCDropDownLost("DdlPS").ddlWS.Attributes.Add("disabled", "disabled")
End If
e.Row.FCTextBox("TxtTiempoEntrega").Enabled = False
'e.Row.FCDropDownList("DdlProyecto").Enabled = False
'e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
e.Row.FCLinkButton("imgD").Visible = False
End If
If UsuarioActual.CveEmpresa.Contiene(7, 122) Then
e.Row.FCTextBox("TxtCantidad").Width = New Unit("100%")
e.Row.FCLabel("LblTurnoEditar").Visible = True
e.Row.FCTextBox("TxtNumTurnosEditar").Visible = True
End If
'If UsuarioActual.CveEmpresa = 119 Then
' e.Row.FCTextBox("TxtDescuento").Enabled = False
'End If
Else
'MODO NORMAL
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
e.Row.FCDropDownList("DdlFR").DataSource = DTPresupuestoIngresos
e.Row.FCDropDownList("DdlFR").DataBind()
e.Row.FCDropDownList("DdlFR").SelectedValue = e.Row.DBCampo("CvePresupuestoIngreso")
'e.Row.FCDropDownList("DdlFR").Enabled = False
End If
If e.Row.DataKey("IEPS").ToDouble > 0 Then : TrIEPS.Visible = True : End If
If NuevaFactura = 1 Then
If Not UsuarioActual.TienePermisoProceso(222) Then
e.Row.FCLinkButton("imgD").Visible = False
e.Row.FCLinkButton("imgE").Visible = False
End If
If TieneAlmacen Then
e.Row.FCLinkButton("imgD").Visible = False
End If
End If
If (CveContrato > 0 AndAlso Not CveVenta > 0) Then
e.Row.FCLinkButton("imgD").Visible = False
End If
'If DdlContratosModal.DataSource IsNot Nothing AndAlso CveCicloComercial <= 0 Then
' e.Row.FCLinkButton("imgE").Visible = False
'End If
'Si es facturacion de OC
If DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 Then
e.Row.FCLinkButton("imgClone").Visible = False
e.Row.FCTextBox("TxtOrden").Visible = True
End If
If UsuarioActual.Empresa.CvePlataforma = 2 Then
e.Row.FCLinkButton("imgE").Visible = False
e.Row.FCLinkButton("imgEPyME").Visible = True
End If
If UsuarioActual.Empresa.Tipo_CentroCosto = 2 Or UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then
e.Row.FCLabel("LblProyecto").Visible = False
End If
If CveVenta > 0 Then 'And e.Row.DBCampo("TipoDocto") = "Rem"
If ModalidadEdicion Then
e.Row.FCLinkButton("imgE").Visible = Not e.Row.DBCampo("CantidadFacturadaRem").ToDouble > 0
e.Row.FCLinkButton("imgD").Visible = Not e.Row.DBCampo("CantidadInventario").ToDouble > 0
ElseIf Not CveDevolucion > 0 Then
e.Row.FCLinkButton("imgE").Visible = False
e.Row.FCLinkButton("imgD").Visible = False
End If
'EN BDH NO DEBE PODER EDITAR LOS PS
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
If ModalidadEdicion Then
e.Row.FCLinkButton("imgE").Visible = True
e.Row.FCLinkButton("imgD").Visible = False
Else
e.Row.FCLinkButton("imgE").Visible = False
e.Row.FCLinkButton("imgD").Visible = False
End If
End If
End If
If UsuarioActual.Empresa.Funcionalidad(360) = "1" AndAlso e.Row.DBCampo("CvePrecioLista").ToEntero() > 0 Then
e.Row.FCLiteral("LtlPrecioLista").Visible = True
End If
If UsuarioActual.CveEmpresa.Contiene(7, 122) AndAlso e.Row.DBCampo("NumTurnos").ToDecimal() > 0 Then
e.Row.FCLiteral("LtlNumTurnos").Visible = True
End If
'CANTIDAD FACTURADA
Select Case e.Row.DBCampo("TipoDocto")
Case "Cot"
e.Row.FCLiteral("LtCantidadFacturada").Text = e.Row.DBCampo("CantidadFacturadaCot").ToDecimal.ToString("#,##0.##")
Case "Pd2"
e.Row.FCLiteral("LtCantidadFacturada").Text = e.Row.DBCampo("CantidadFacturadaPed2").ToDecimal.ToString("#,##0.##")
End Select
If EsCreaApartirDe Then
e.Row.FCLinkButton("imgD").Visible = True
e.Row.FCLinkButton("imgE").Visible = True
End If
'If GvInv.Rows.Count > 0 AndAlso ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem" AndAlso e.Row.DataKey("CveVentaDetalle").ToString().ToEntero() > 0 Then
' e.Row.FCLinkButton("imgE").Enabled = False
' e.Row.FCLinkButton("imgE").ToolTip = "No se puede editar debido a que ya hay un movimiento de almacen."
'End If
End If
End If
End Sub
Protected Sub GvPS_RowEditing(sender As Object, e As EventArgs) Handles GvPS.RowEditing
'ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs
'
LimpiaAgregar()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
IndicePSActual = GvRow.RowIndex
CantidadOriginal = GvRow.DataKey("Cantidad").ToDecimal
TxtCantidad.Text = GvRow.DataKey("Cantidad")
DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion"))
If UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1" Then
DdlPS.txtValue.Value = GvRow.DataKey("CvePS")
DdlPS.txtText.Value = GvRow.DataKey("CodigoPS")
Else
DdlPS.ddl.SelectedValueExist(GvRow.DataKey("CvePS"))
End If
TxtObsPS.Text = GvRow.DataKey("Obs")
TxtPrecio.Text = GvRow.DataKey("PU")
TxtCantidad.Focus()
UpDVAddPS.Update()
RegistraScript("$('#DVAddPS').modal();")
'''************
'GvPS.EditIndex = e.NewEditIndex
'GvPS.DataSource = TmpDT
'DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
'GvPS.DataBind()
'If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlUnidadMedida").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlClasificacion").Enabled = False
'End If
''SI ES LLANTERA NO DEBE BLOQUEAR EL TEXTBOX
'If GvPS.Rows(e.NewEditIndex).DataKey("CvePromocionDetalle").ToString().ToEntero() > 0 AndAlso (Not UsuarioActual.Empresa.Funcionalidad(558) = "1") Then
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtDescuento").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtDescuento").ToolTip = "No se puede editar el descuento porque viene de una promoción"
'End If
'If Me.CveVenta > 0 AndAlso UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Cot") Then
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtDescuento").Enabled = False
'End If
'If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtCantidad").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlUnidadMedida").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownLost("DdlPS").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownLost("DdlPS").ddlWS.Attributes.Add("disabled", "disabled")
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlUnidadMedida").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlClasificacion").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlProyecto").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCDropDownList("DdlSubProyecto").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtObsPS").Enabled = True
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = False
' GvPS.Rows(e.NewEditIndex).FCTextBox("TxtDescuento").Enabled = False
'End If
End Sub
'Protected Sub GvPS_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvPS.RowCancelingEdit
' GvPS.EditIndex = -1
' GvPS.DataSource = TmpDT
' DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
' GvPS.DataBind()
'End Sub
'Protected Sub GvPS_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvPS.RowUpdating
' 'Dim TipoDescuento As Integer
' Dim Cantidad, PU, CantidadInventario As Decimal
' Dim ObjDescuento As New Modelos.VentaDescuentos
' Dim CuentaPredial As String
' Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal
' PU = (GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDecimal).RoundSQL(6)
' Dim DescuentoManual As Decimal = (GvPS.Rows(e.RowIndex).FCTextBox("TxtDescuento").Text.ToDecimal).RoundSQL(NumeroDecimales)
' ObjDescuento.ImporteDescuento = DescuentoManual
' CuentaPredial = GvPS.Rows(e.RowIndex).FCTextBox("TxtPredial").Text.Trim
' If PU <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
' Alert("El precio debe ser mayor a 0", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' If UsuarioActual.CveEmpresa = 140 OrElse DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then
' ObjDescuento = CalcularDescuentos(TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero(), Cantidad, PU)
' End If
' 'SI ESTA HABILITADO LA OPCION DE DESCUENTO, SE AGREGO UN DESCUENTO MANUAL Y NO TIENE PROMOCION
' If GvPS.Rows(e.RowIndex).FCTextBox("TxtDescuento").Enabled AndAlso (ObjDescuento.CvePromocionDetalle <= 0 AndAlso ObjDescuento.ImporteDescuento <= 0) AndAlso DescuentoManual > 0 Then
' ObjDescuento.ImporteDescuento = DescuentoManual
' End If
' 'VERIFICA SI EL DESCUENTO SUPERA EL SUBTOTAL
' If ObjDescuento.ImporteDescuento.RoundSQL(2) > (Cantidad * PU).RoundSQL(2) Then
' Alert("El descuento no puede ser mayor al subtotal", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' Dim CantidadOriginal As Decimal = GvPS.Rows(e.RowIndex).DataKey("Cantidad").ToDecimal()
' Dim DatarowPS As DataRow = Nothing
' DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") ' Estado = -1
' 'verifica si tiene ventaminima
' If Cantidad > 0 AndAlso DatarowPS("VentaMinima").ToString().ToDecimal > 0 AndAlso (DdlTipoComprobante.SelectedValue = "Rem" Or DdlTipoComprobante.SelectedValue = "Ing") Then
' 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
' If Cantidad Mod DatarowPS("VentaMinima").ToString().ToDecimal <> 0 Then
' Alert(String.Format("El producto se vende solo en cantidades de {0}", DatarowPS("VentaMinima").ToString()))
' Exit Sub
' End If
' End If
' 'si es remisión, ingreso, anticipo debe de considerar el preciominimo
' If Not UsuarioActual.TienePermisoProceso(169) Then ' NO VALIDA EXISTENCIAS NI COSTO - PERMISO PARA NO VALIDAR
' Dim CvePS As Integer = DatarowPS("CvePS").ToString().ToEntero()
' Dim CveUM As Integer = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero() 'DatarowPS("CveUM").ToString().ToEntero()
' Dim CveTipoPS As Integer = DatarowPS("CveTipoPS").ToString().ToEntero()
' CantidadInventario = GvPS.Rows(e.RowIndex).DataKey("CantidadInventario").ToDecimal
' Dim CveUMInicial As Integer = GvPS.Rows(e.RowIndex).DataKey("CveUM").ToEntero
' Dim ValidaExistencia As Boolean = True
' If (CantidadInventario > 0) OrElse (Cantidad <= CantidadOriginal) Then 'si ya hay algo surtido, que no valide existencia
' ValidaExistencia = False
' End If
' If CveUM <> CveUMInicial Then ValidaExistencia = True
' 'SOLO VALIDA EXISTENCIAS Y COSTO: SI USA INVENTARIOS, SOLO PRODUCTOS TIPO PRODUCTO, SOLO REMISIONES E INGRESOS
' If UsuarioActual.Empresa.UsaInventarios AndAlso CveTipoPS = 2 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119))) Then
' Dim ObjInventarios As New ClsInventarios
' Dim Existencia As Decimal
' If ValidaExistencia Then
' Existencia = ObjInventarios.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveVendedor:=-1, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, RestringirAlmacenes:=1, ExcluyeApartados:=-1)
' End If
' Dim Costo As Decimal = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", NowADS, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
' 'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal
' If Costo <= 0 Then Costo = ObjInventarios.GetCostoPS(CvePS, TxtCantidad.Text.Trim.ToDecimal, -1, "-1", NowADS, -1, CveTipoAlmacen:=1)
' ObjInventarios.Dispose()
' Dim PrecioMinimo As Decimal = 0
' 'RMF. condicion temporal, para reubicación, precio mínimo
' If UsuarioActual.CveEmpresa = 119 Then
' 'Dim CvePrecioLista As Integer = 38
' Dim objPS As New ClsProductosServicios
' If objPS.GetPSSucursalesALL(CvePS, UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero()) Then
' PrecioMinimo = objPS.DtResultados.FiltroPrimeroValor("PrecioMinimo", "").ToDecimal
' 'If PrecioMinimo > 0 Then
' ' Costo = PrecioMinimo
' 'End If
' End If
' objPS.Dispose()
' End If
' If ValidaExistencia AndAlso DdlTipoComprobante.SelectedValue <> "Cot" AndAlso Not RegistroxOC Then
' 'VALIDA EXISTENCIA
' If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 140, 153}) Then
' 'SI ES VENTA NUEVA TOMA EN CUENTA LO DEL TMPDT
' If CveVenta <= 0 Then
' If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then
' Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' Else
' If DdlTipoComprobante.SelectedValue = "Rem" Then
' Dim CantidadVenta As Double = 0
' Using ObjVentas As New ClsVentas
' If ObjVentas.GetVentaDetalle(CveVenta) Then
' CantidadVenta = ObjVentas.DtResultados.SUM("Cantidad", $"CvePS = {CvePS}")
' End If
' End Using
' 'SUMA LO YA RESTADO EN PENDIENTE POR SURTIR QUE PERTENESCA A LA VENTA.
' 'PARA QUE NO RESTE LA EXISTENCIA 2 VECES Y PUEDAS COMPARAR LO REAL
' If (Existencia + CantidadVenta) - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then
' Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' End If
' End If
' End If
' End If
' 'VALIDA COSTOS
' If Not CveContrato > 0 Then
' 'BANDERAS PARA VALIDACIONES
' Dim EsValido As Boolean = False
' Dim EsValidoMayor As Boolean = False
' Dim CostoMenor As Decimal = 0
' Dim CostoMayor As Decimal = 0
' 'PRECIO MINIMO
' If UsuarioActual.Empresa.Funcionalidad(129).ToEntero() > 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
' '' NOTA. si tiene preciominimo, debe de validarlos e ignorar el costo, pero se debe de considerar el TC, para el costo
' If PrecioMinimo > 0 Then
' 'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
' If PU >= PrecioMinimo Then ' aqui se comparar los importes directos, sin el TC
' EsValido = True
' End If
' Else
' CostoMenor = Costo + ((UsuarioActual.Empresa.Funcionalidad(129).ToDecimal / 100) * Costo)
' 'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
' If PU * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal) >= CostoMenor Then
' EsValido = True
' End If
' End If
' Else
' EsValido = True
' End If
' 'PRECIO MAXIMO
' If UsuarioActual.Empresa.Funcionalidad(133).ToEntero() > 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
' CostoMayor = Costo + ((UsuarioActual.Empresa.Funcionalidad(133).ToDecimal / 100) * Costo)
' 'SI EL PRECIO ES MAYOR AL COSTO MAXIMO, SI PASA
' If PU * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal) <= CostoMayor Then
' EsValidoMayor = True
' End If
' Else
' EsValidoMayor = True
' End If
' 'NO DEJA REGISTRAR MENOS AL PRECIO MINIMO
' Dim MensajeCosto As New StringBuilder
' Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
' If Not EsValido Then
' MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio menor de su Costo
", DatarowPS("PS").ToString())
' If TienePermisoImportes Then
' MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00}
", Costo)
' MensajeCosto.AppendFormat("El rango menor aceptado es: {0:#,###.00}% ${1}
", UsuarioActual.Empresa.Funcionalidad(129).ToEntero(), CostoMenor)
' MensajeCosto.AppendFormat("El precio indicado es: ${0:#,###.00} ({1}% de ganancia)
", PU.FormatoNumero, (If(Costo > 0, ((PU - Costo) * 100) / Costo, 0)).FormatoNumero)
' End If
' Alert(String.Format(MensajeCosto.ToString()), TipoMensaje.MsgAdvertencia)
' MensajeCosto.Clear()
' e.Cancel = True
' Exit Sub
' End If
' 'NO DEJA REGISTRAR MAS AL PRECIO MAXIMO
' If Not EsValidoMayor Then
' MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio mayor de su rango aceptado
", HdnPS.Value)
' If TienePermisoImportes Then
' MensajeCosto.AppendFormat("El costo del producto es: ${0:#,###.00}
", Costo)
' MensajeCosto.AppendFormat("El rango mayor aceptado es: {0}% ${1:#,###.00}
", UsuarioActual.Empresa.Funcionalidad(133).ToEntero(), CostoMayor)
' MensajeCosto.AppendFormat("El precio indicado es: ${0:#,###.00} ({1}% de ganancia)
", PU.FormatoNumero, (If(Costo > 0, ((PU - Costo) * 100) / Costo, 0)).FormatoNumero)
' End If
' Alert(MensajeCosto.ToString(), TipoMensaje.MsgAdvertencia)
' MensajeCosto.Clear()
' e.Cancel = True
' Exit Sub
' End If
' End If
' End If
' End If
' If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing AndAlso ObjDescuento IsNot Nothing Then
' Dim ConsecEliminar As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero()
' If ConsecEliminar > 0 Then
' Dim descEliminar As Modelos.VentaDescuentos = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar)
' If descEliminar IsNot Nothing Then
' ListaDescuentos.Remove(descEliminar)
' End If
' End If
' End If
' If TmpDT.Rows(e.RowIndex)("CvePS").ToString() <> GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue Then
' 'eliminar y cargar el ps ***
' Dim DdlUM As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida")
' Dim DdlCla As DropDownList = GvPS.Rows(e.RowIndex).FCDropDownList("DdlClasificacion")
' If DtPromociones IsNot Nothing AndAlso DtPromociones.Rows.Count > 0 Then
' ObjDescuento = CalcularDescuentos(GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue.ToEntero(), Cantidad, PU)
' End If
' Dim NumTurnos As Decimal = 0
' If UsuarioActual.CveEmpresa.Contiene(7, 122) Then
' NumTurnos = GvPS.Rows(e.RowIndex).FCTextBox("TxtNumTurnosEditar").Text.ToDecimal()
' End If
' TmpDT.Rows.Remove(TmpDT.Rows(e.RowIndex))
' 'CalculaUsados()
' AgregarProductoServicio(Cantidad, DdlUM.SelectedValue.ToEntero(), DdlUM.SelectedItem.Text, DdlCla.SelectedValue.ToEntero(), DdlCla.SelectedItem.Text,
' GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedValue.ToEntero(), GvPS.Rows(e.RowIndex).FCDropDownLost("DdlPS").SelectedText,
' GvPS.Rows(e.RowIndex).FCTextBox("TxtObsPS").Text.Trim, PU, ObjDescuento.ImporteDescuento,
' GvPS.Rows(e.RowIndex).FCDropDownList("DdlProyecto").SelectedValue.ToEntero(), GvPS.Rows(e.RowIndex).FCDropDownList("DdlProyecto").SelectedItem.Text,
' GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero(), GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedItem.Text,
' CuentaPredial:=CuentaPredial, CveVentaDetalle:=GvPS.Rows(e.RowIndex).DataKey("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle,
' ObjDescuento:=ObjDescuento, NumTurnos:=NumTurnos)
' ' TmpDT.Rows(e.RowIndex)("CveUM") = Ddl.SelectedValue
' ' TmpDT.Rows(e.RowIndex)("UM") = Ddl.SelectedItem.Text
' GvPS.EditIndex = -1
' GvPS.DataSource = TmpDT
' DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
' GvPS.DataBind()
' Else
' Dim DrPS As DataRow = Nothing
' DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
' If Not ClienteDesglosaIEPS Then
' PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
' TmpDT.Rows(e.RowIndex)("PorcentajeIEPS") = 0
' End If
' Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento))
' Dim TotalCalculableImpuestosIVA As Decimal = 0
' TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + TmpDT.Rows(e.RowIndex)("PorcentajeIEPS").ToString().ToDecimal)
' Dim ClienteRetIVA As Decimal = Me.ClienteRetIVA
' If ClienteRetIVA <= 0 Then
' If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then
' ClienteRetIVA = 0.106667D
' ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then
' ClienteRetIVA = 0.04D
' End If
' End If
' If DrPS("IVA").ToString().Contiene("-1", "") Then
' TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = PorcentajeIVA
' Else
' TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = DrPS("IVA")
' End If
' If UsuarioActual.Empresa.Funcionalidad(373) = "1" AndAlso LblRFC.Text = "XEXX010101000" Then
' TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = 0
' TmpDT.Rows(e.RowIndex)("ImporteIVA") = 0
' End If
' TmpDT.Rows(e.RowIndex)("CveUM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero()
' TmpDT.Rows(e.RowIndex)("UM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedItem.Text
' TmpDT.Rows(e.RowIndex)("Cantidad") = Cantidad
' TmpDT.Rows(e.RowIndex)("Obs") = GvPS.Rows(e.RowIndex).FCTextBox("TxtObsPS").Text.TrimEnd
' TmpDT.Rows(e.RowIndex)("TiempoEntrega") = GvPS.Rows(e.RowIndex).FCTextBox("TxtTiempoEntrega").Text.Trim
' TmpDT.Rows(e.RowIndex)("PU") = PU
' TmpDT.Rows(e.RowIndex)("Descuento") = ObjDescuento.ImporteDescuento
' TmpDT.Rows(e.RowIndex)("Total") = (Cantidad * PU)
' TmpDT.Rows(e.RowIndex)("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("ImporteIVA") = (TmpDT.Rows(e.RowIndex)("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("ImporteIEPS") = (TmpDT.Rows(e.RowIndex)("PorcentajeIEPS").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
' TmpDT.Rows(e.RowIndex)("PorcentajeRetIVA") = ClienteRetIVA
' TmpDT.Rows(e.RowIndex)("PorcentajeRetISR") = ClienteRetISR
' TmpDT.Rows(e.RowIndex)("CuentaPredial") = CuentaPredial
' Dim NumTurnos As Decimal = 0
' If UsuarioActual.CveEmpresa.Contiene(7, 122) Then
' NumTurnos = GvPS.Rows(e.RowIndex).FCTextBox("TxtNumTurnosEditar").Text.ToDecimal()
' End If
' TmpDT.Rows(e.RowIndex)("NumTurnos") = NumTurnos
' If ObjDescuento IsNot Nothing Then
' TmpDT.Rows(e.RowIndex)("CvePromocionDetalle") = ObjDescuento.CvePromocionDetalle
' End If
' If GvPS.Rows(e.RowIndex).FCDropDownList("DdlProyecto").Items.Count = 0 Then
' TmpDT.Rows(e.RowIndex)("Proyecto") = "Sin Proyecto Asignado"
' TmpDT.Rows(e.RowIndex)("CveSubProyecto") = -1
' Else
' TmpDT.Rows(e.RowIndex)("Proyecto") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlProyecto").SelectedItem.Text
' End If
' If GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").Items.Count = 0 Then
' TmpDT.Rows(e.RowIndex)("SubProyecto") = "Sin SubProyecto Asignado"
' Else
' 'si está visible en el encabezado, si no esta visible que no actualice, porque generar error, selecciona el primer item
' TmpDT.Rows(e.RowIndex)("SubProyecto") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedItem.Text
' TmpDT.Rows(e.RowIndex)("CveSubProyecto") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedValue
' End If
' 'RELACIONAL PS CON EL DESCUENTO
' If ObjDescuento IsNot Nothing Then
' ObjDescuento.Consec = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero()
' End If
' DrPS = Nothing
' GvPS.EditIndex = -1
' GvPS.DataSource = TmpDT
' DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
' GvPS.DataBind()
' End If
' If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing AndAlso ObjDescuento IsNot Nothing Then
' ListaDescuentos.Add(ObjDescuento)
' End If
' CalculaTotalesVenta()
' UpPS.Update()
'End Sub
Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvPS.RowDeleting
If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ListaDescuentos IsNot Nothing Then
Dim ConsecEliminar As Integer = TmpDT.Rows(e.RowIndex)("Consec").ToString().ToEntero()
If ConsecEliminar > 0 Then
Dim descEliminar As Modelos.VentaDescuentos = ListaDescuentos.FirstOrDefault(Function(x) x.Consec = ConsecEliminar)
If descEliminar IsNot Nothing Then
ListaDescuentos.Remove(descEliminar)
End If
End If
End If
Dim DbRow As DataRow = Nothing
DbRow = TmpDT.Rows(e.RowIndex)
TmpDT.Rows.Remove(DbRow)
'CalculaUsados()
GvPS.DataSource = TmpDT
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
GvPS.DataBind()
'CargaGVInv(DtInv)
CalculaTotalesVenta()
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
'JJMQ 20160506: Se agrego para la validacion de pago de contado.
'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "")
End Sub
#End Region
#Region " EMITIR IMPRIMIR - GUARDAR "
Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click
Try
EmitirImprimir()
Catch ex As Exception
OnError(ex.ToString(), ex)
End Try
End Sub
Private Sub EmitirImprimir(Optional TipoDoctoViejo As String = "")
DtRemisionesTmpDT = TmpDT.Copy
DtPedidos2TmpDT = TmpDT.Copy
DtCotizacionTmpDT = TmpDT.Copy
DtOCTmpDT = TmpDT.Copy
TmpDTError = TmpDT.Copy
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Egs", "Dev") Then
If RegimenFiscalCliente.Contiene("-1", "") Then
Alert("El cliente no tiene asignado un régimen fiscal.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If DdlUsoCFDI.SelectedValue.ToEntero() <= 0 Then
Alert("No se ha seleccionado el Uso CFDI o el cliente no tiene asignado el correcto.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs", "Dev") Then
If LblRFC.Text.Trim().ToUpper().Contiene("XAXX010101000", "XEXX010101000") AndAlso RegimenFiscalCliente <> "616" Then
Alert("El Regimen fiscal del cliente debe ser '616 - Sin obligaciones fiscales' cuando se utiliza el RFC genérico.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If LblRFC.Text.Trim().ToUpper().Contiene("XAXX010101000", "XEXX010101000") AndAlso DdlUsoCFDI.SelectedValue <> "23" Then
Alert("El uso cfdi del cliente debe ser 'S01 - Sin efectos fiscales' cuando se utiliza el RFC genérico.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If Not LblRFC.Text.Trim().ToUpper().Contiene("XAXX010101000", "XEXX010101000") AndAlso RegimenFiscalCliente = "616" Then
Alert("El Regimen fiscal del cliente no puede ser '616 - Sin obligaciones fiscales' si no se utiliza el RFC genérico.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim EsPersonaMoral As Boolean = Me.TipoPersona
Dim DtUsosCFDI As DataTable = GlobalDTSATUsosCFDI(If(Not EsPersonaMoral, 1, 0), RegimenFiscalReceptor:=RegimenFiscalCliente).FiltraParametros($"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}")
If DtUsosCFDI.Rows.Count = 0 Then
Alert("El Uso CFDI no corresponde con el tipo de persona (fisca, moral) y el régimen fiscal.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If Not ValidaImportePublicoGeneral() Then
Exit Sub
End If
If (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) Then
Alert("La sucursal no tiene asignada un RFC.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VALIDACIONES
If Not CveCliente > 0 And Not CveEmpresaCRM > 0 Then
Alert("Es necesario seleccionar el cliente al cual se le va a facturar.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TmpDT Is Nothing OrElse TmpDT.Rows.Count = 0 Then
Alert("Es necesario tener al menos un concepto registrado.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'Subproyecto Obligatorio
If UsuarioActual.Empresa.Funcionalidad(120) = "1" AndAlso TmpDT.FiltraParametros("ISNULL(CveSubProyecto,0) <= 0").Rows.Count > 0 Then
Alert("El Subproyecto de los conceptos es obligatorio, Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VENDEDOR OBLIGATORIO
If -1 <= 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then
Alert("Debe seleccionar un vendedor.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'SI TIENE ANTICIPOS Y ESTA AMORTIZADO AL 100% EL DOCUMENTO (SALDO = 0) | NO VALIDA PU DEL CONCEPTO
If Not (LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0) Then
If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "Ant", "DPe") Then
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
If TmpDT.FiltraParametros($"TotalImporte = 0").Rows.Count > 0 Then
Alert("El importe de cada concepto debe ser mayor a cero. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
End If
Dim CveContratoTipo As Integer = 0
If CveContrato > 0 Then
Dim ObjContrato As New ClsContratos
If ObjContrato.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
If ObjContrato.DtResultados.Rows.Count > 0 Then
CveContratoTipo = ObjContrato.DtResultados.Rows(0)("CveContratoTipo").ToString().ToEntero()
End If
End If
ObjContrato.Dispose()
End If
Me.CveAutorizacion = -1
'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") Then
Dim TipoDocumentoAutorizacion As String = ""
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim DiasVencidosAutorizacion As Integer = 0
Dim CveVendedor As Integer = -1
Dim ObjVentas As New ClsVentas
ObjVentas.Dispose()
If TipoDocumentoAutorizacion = "Ing" Then
If TipoAutorizacion = 1 Then
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
Dim BloquearCredito As Boolean = True
CveAutorizacion = -1
'VERIFICA SI TIENE CREDITO DISPONIBLE DENTRO DEL CLIENTE
Dim ObjCred As New ClsVentas
If ObjCred.ObtenerCreditoRestante(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) AndAlso ObjCred.DtResultados.Rows.Count > 0 Then
'SI TIENE CREDITO DISPONIBLE NO BLOQUEAR AUNQUE LA AUTORIZACION NO TENGA EL IMPORTE DEL DOCUMENTO
If DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then
If (ObjCred.DtResultados(0)("LimiteRestanteSucursal").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal)) > 0 Then
BloquearCredito = False
End If
Else
If (ObjCred.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal)) > 0 Then
BloquearCredito = False
End If
End If
End If
ObjCred.Dispose()
If BloquearCredito Then
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
'If TipoAutorizacion = 2 Then
' If DiasVencidosCliente > DiasVencidosAutorizacion Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
'End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TipoDocumentoAutorizacion = "Egs" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
End If
'SI TIENE LINEA ADICIONAL NO VERIFICAR LIMITE DE CREDITO
'SI NO TIENE AUTORIZACION VERIFICAR LIMITE DE CREDITO Y CANDADOS DE VENTA
'No exceder el limite de credito, Si no tiene contrato limita el credito, si tiene no hace nada. Si no tiene remisiones tampoco hace nada.
'If DdlLineaAdicional.SelectedValue.ToEntero() <= 0 AndAlso Me.CveAutorizacion <= 0 AndAlso (Not CveContrato > 0 Or CveContratoTipo.Contiene(28)) AndAlso (Not NuevaFactura = 1) AndAlso RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso RemisionesLista.Count <= 0 AndAlso TxtTotal.Text.ToDecimal > 0 AndAlso Not CvePedidoA > 0 Then
' 'If UsuarioActual.Empresa.Funcionalidad(518) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(185) Then
' If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then
' Dim ObjVentas As New ClsVentas
' If ObjVentas.ObtenerCreditoRestante(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) Then
' If ObjVentas.DtResultados.Rows.Count > 0 Then
' If DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then
' If ObjVentas.DtResultados(0)("LimiteRestanteSucursal").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal) < 0 Then
' ObjVentas.Dispose()
' Alert("Se está excediendo el límite de credito permitido de la Sucursal del Cliente.", TipoMensaje.MsgInformacion)
' Exit Sub
' End If
' Else
' If ObjVentas.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal) < 0 Then
' ObjVentas.Dispose()
' Alert("Se está excediendo el límite de credito permitido del Cliente.", TipoMensaje.MsgInformacion)
' Exit Sub
' End If
' End If
' Else
' ObjVentas.Dispose()
' Alert("Ocurrio un error al obtener el limite de credito del cliente", TipoMensaje.MsgError)
' Exit Sub
' End If
' Else
' ObjVentas.Dispose()
' Alert("Ocurrio un error al obtener el limite de credito del cliente", TipoMensaje.MsgError)
' Exit Sub
' End If
' ObjVentas.Dispose()
' 'VERIFICA SI TIENE BLOQUEO POR DIAS VENCIDOS
' If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
' Dim Vta As New ClsVentas
' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa, TipoVerificacion:=2)
' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:
{0}", Vta.SerieVenta)
' Vta.Dispose()
' If Opcion = 2 Then
' Alert(OpcionMsg, TipoMensaje.MsgError)
' Exit Sub
' End If
' End If
' End If
' 'End If
'End If
'VALIDA PRECIO AL AGREGAR A ALMACEN
If Not UsuarioActual.TienePermisoProceso(169) Then
If (DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "PA") AndAlso NuevaFactura <> 1) Or (DdlTipoComprobante.SelectedValue = "Cot" AndAlso BtnEmitirImprimir.Text = "Facturar") Or (DdlTipoComprobante.SelectedValue.Contiene("Cot") And UsuarioActual.CveEmpresa.Contiene(119)) Then
Dim MensajeCosto As New StringBuilder
Dim CostoMenor As Decimal = 0.0D
Dim CostoMayor As Decimal = 0.0D
Dim Costo As Decimal = 0.0D
Dim EsValido As Boolean = False 'BANDERA
Dim EsValidoMayor As Boolean = False
Dim EsValidoPU As Boolean = True 'SOLO SE VALIDA CUANDO EL TXTPU = 0 Y LO INVALIDA ALGUNA PROMOCION
'VALIDA PROMOCIONES Y EXISTENCIAS
Dim ObjVentas As New ClsVentas
If ObjVentas.GetPromocionesPS(-1, NowADS, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, -1, 1, UsuarioActual.CveEmpresa) Then
DtPromociones = ObjVentas.DtResultados
End If
ObjVentas.Dispose()
Dim ObjInventarios As New ClsInventarios
Dim PU As Decimal = 0.0D
Dim Cantidad As Double
Dim CveUnidad As Integer
Dim CveProducto As Integer
Dim Existencia As Double
' Dim CveAlmacen As Integer = ddlAlmacen.SelectedValue.ToEntero()
For Each dr As DataRow In TmpDT.FiltraParametros("CveTipoPS = 2").Rows
If DdlTipoComprobante.SelectedValue <> "Cot" Then
'VALIDA EXISTENCIA
CveProducto = dr("CvePS").ToString().ToEntero()
CveUnidad = dr("CveUM").ToString().ToEntero()
Cantidad = TmpDT.SUM("Cantidad", $"CvePS = {CveProducto} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") 'VALIDA CONTRA LA SUMA DEL MISMO PS
If UsuarioActual.Empresa.UsaInventarios AndAlso RemisionesLista.Count < 1 AndAlso dr("EntregaDirecta").ToString().ToEntero() < 1 Then
Existencia = ObjInventarios.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveVendedor:=-1, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1, RestringirAlmacenes:=1, ExcluyeApartados:=-1)
If Existencia < Cantidad Then
MensajeCosto.AppendFormat("
El Producto {0}. No cuenta con la cantidad suficiente en inventario. Cuenta con {1}.", dr("CodigoPS").ToString(), Existencia.FormatoNumero(2))
Continue For
End If
End If
End If
EsValido = False
EsValidoMayor = False
EsValidoPU = True
PU = dr("PU").ToString().ToDecimal * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal)
Costo = ObjInventarios.GetCostoPS(dr("CvePS").ToString().ToEntero(), dr("Cantidad").ToString().ToDecimal, -1, "-1", NowADS, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
Dim PrecioMinimo As Decimal = 0
'RMF. condicion temporal, para reubicación, precio mínimo
If UsuarioActual.CveEmpresa = 119 Then
'Dim CvePrecioLista As Integer = 38
Dim objPS As New ClsProductosServicios
If objPS.GetPSSucursalesALL(dr("CvePS").ToString().ToEntero(), UsuarioActual.CveEmpresa, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero()) Then
PrecioMinimo = objPS.DtResultados.FiltroPrimeroValor("PrecioMinimo", "").ToDecimal
'If PrecioMinimo > 0 Then
' Costo = PrecioMinimo
'End If
End If
objPS.Dispose()
End If
'PRECIO MINIMO
If UsuarioActual.Empresa.Funcionalidad(129).ToEntero() > 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
'' NOTA. si tiene preciominimo, debe de validarlos e ignorar el costo, pero se debe de considerar el TC, para el costo
If PrecioMinimo > 0 Then
'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
If PU >= PrecioMinimo Then ' aqui se comparar los importes directos, sin el TC
EsValido = True
End If
Else
CostoMenor = Costo + ((UsuarioActual.Empresa.Funcionalidad(129).ToDecimal / 100) * Costo)
'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
If PU * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal) >= CostoMenor Then
EsValido = True
End If
End If
Else
EsValido = True
End If
If UsuarioActual.Empresa.Funcionalidad(133).ToEntero() > 0 AndAlso UsuarioActual.CveUsuario <> 1560 Then
CostoMayor = Costo + ((UsuarioActual.Empresa.Funcionalidad(133).ToDecimal / 100) * Costo)
'SI EL PRECIO ES MAYOR AL COSTO, SI PASA
If PU <= CostoMayor Then
EsValidoMayor = True
End If
Else
EsValidoMayor = True
End If
'VALIDA PROMOCION: SI TIENE PROMOCION Y EL PRECIO ES MENOR AL PRECIO DE PROMOCION, NO PASA | SI YA CUMPLE NO VUELVE A VALIDAR
If Not EsValido Or PU = 0 Then
If DtPromociones.FiltraParametros($"CvePS = {dr("CvePS").ToString().ToEntero()}").Rows.Count > 0 Then
If PU * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal) >= DtPromociones.FiltroPrimeroValor("PUPromocion", $"CvePS = {dr("CvePS").ToString().ToEntero()}").ToDecimal Then
EsValido = True
Else
EsValidoPU = False ' SI NO ENTRA DENTRO DE LA PROMOCION NO SE PUEDE VENDER A 0
End If
Else
EsValidoPU = False ' SI NO TIENE PROMOCION NO SE PUEDE VENDER A 0
End If
End If
'NO DEJA REGISTRAR CON VALIDACION DE COSTO ALMACEN O PROMOCION
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
If Not EsValido Then
MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio menor de su Costo ni a un precio mayor de su rango aceptado
", dr("PS").ToString())
If TienePermisoImportes Then
MensajeCosto.AppendFormat("El costo del producto es: {0:#,###.00}$
", Costo)
MensajeCosto.AppendFormat("El rango menor aceptado es: {0} {1:#,###.00}$
", UsuarioActual.Empresa.Funcionalidad(129).ToEntero(), CostoMenor)
MensajeCosto.AppendFormat("El precio indicado es: {0:#,###.00}$ ({1}% de ganancia)
", PU.FormatoNumero, If(Costo > 0, ((PU - Costo) * 100) / Costo, 0))
End If
End If
If Not EsValidoMayor Then
MensajeCosto.AppendFormat("El Producto {0}. No se puede vender a un precio mayor de su rango aceptado
", dr("PS").ToString())
If TienePermisoImportes Then
MensajeCosto.AppendFormat("El costo del producto es: {0:#,###.00}$
", Costo)
MensajeCosto.AppendFormat("El rango mayor aceptado es: {0} {1:#,###.00}$
", UsuarioActual.Empresa.Funcionalidad(133).ToEntero(), CostoMayor)
MensajeCosto.AppendFormat("El precio indicado es: {0:#,###.00}$ ({1}% de ganancia)
", PU.FormatoNumero, If(Costo > 0, ((PU - Costo) * 100) / Costo, 0))
End If
End If
' SOLO SI TIENE LA FUNCIONALIDAD DE RESTRICCION VALIDA EL IMPORTE CERO
If UsuarioActual.Empresa.Funcionalidad(139).ToString().ToEntero() > 0 Then
If Not EsValidoPU Then
MensajeCosto.AppendFormat($"El producto {dr("PS").ToString()}. No se puede vender a un importe de cero ($0)", TipoMensaje.MsgAdvertencia)
End If
End If
Next
ObjInventarios.Dispose()
If MensajeCosto.ToString().Length > 1 Then
Alert(MensajeCosto.ToString(), TipoMensaje.MsgAdvertencia)
MensajeCosto.Clear()
Exit Sub
End If
End If
End If
'Valida si en caso de que el detalle tenga llantas o polizas se agreguén kilometraje/serie en la parte de observaciones(solo para el caso de empresas llanteras)
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
If TxtObsFact.Text = "" Then
Dim FaltaObservacion As Integer = -1
FaltaObservacion = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20345").ToEntero()
'cuando es la clasificacion de polizas
If FaltaObservacion = 20345 Then
Alert("No se ha especificado la serie para la poliza en la sección de Observaciones", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If UsuarioActual.Empresa.Funcionalidad(135) = "1" And DdlTipoComprobante.SelectedValue = "Cot" Then
Alert("Se mando autorización al supervisor.", TipoMensaje.MsgInformacion)
MandarCorreoSupervisor = True
Dim CorreoSupervisor As String = ""
Dim Objeto As New ClsVtaVendedores
Dim DTSupervisores As New DataTable
If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then
DTSupervisores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", -1))
'Verifico si el supervisor tiene correo para proceder
If DTSupervisores.Rows.Count > 0 Then
CorreoSupervisor = DTSupervisores.Rows(0)("CorreoSupervisor").ToString()
End If
End If
DTSupervisores.Dispose()
Objeto.Dispose()
If MandarCorreoSupervisor = True And CorreoSupervisor <> "" Then
ViewState("Mail") = CorreoSupervisor
End If
MandarCorreoSupervisor = False
End If
If RequiereOC AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Ing") AndAlso Not CveDevolucion > 0 Then
If Not CargaDocumentoOC Then
Alert("Tiene que cargar un archivo de orden de compra", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtOrdenCompra.Text.Trim = "" Then
Alert("Tiene que especificar un folio de orden de compra", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
'If DivAlmacen.Visible AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Dev") AndAlso GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) > 0 AndAlso ddlAlmacen.SelectedValue.ToEntero() <= 0 Then
' Alert("Tiene que seleccionar un almacén para la salida de almacén", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
EmitirImprimirNew(TipoDoctoViejo)
End Sub
#End Region
#Region " NNNNEEEEEEEWWWWWW "
Private Sub InicializaImprimirNew()
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta))
Dim Archivo2 As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta))
Dim ArchivoSti As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta))
Dim ArchivoSti2 As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.mrt", UsuarioActual.Empresa.Ruta))
Dim ArchivoSti3 As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.mrt", UsuarioActual.Empresa.Ruta))
UpnTools.Update()
End Sub
Protected Sub EmitirImprimirNew(Optional TipoDoctoViejo As String = "")
'If Not ValidaVentaContratoObra() Then
' Exit Sub
'End If
'If ValidaPagosContado(TipoDoctoViejo:=TipoDoctoViejo) Then
' Exit Sub
'End If
'validaciones, si es Anticipo solo permitir "servicios de facturación" y si es ingreso todos menos serv. factu
If UsuarioActual.CveEmpresa = 119 Then
If DdlTipoComprobante.SelectedValue = "Ing" Then
Dim tCont As Integer = TmpDT.FiltraParametros("SATClaveProdServ='84111506'").Rows.Count
If tCont > 0 Then
Alert("Existen productos con código SAT '84111506' no permitido al facturar ingresos.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If DdlTipoComprobante.SelectedValue = "Ant" Then
Dim tCont As Integer = TmpDT.FiltraParametros("SATClaveProdServ<>'84111506'").Rows.Count
If tCont > 0 Then
Alert("Al facturar 'Anticipos' solo son permitidos código SAT '84111506'.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
'CREA UNA COPIA DE SEGURIDAD PARA LOS DATOS DEL TMPDT
If TmpDTError Is Nothing OrElse TmpDTError.Rows.Count = 0 Then
TmpDTError = TmpDT.Copy()
End If
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso TbDescuentosAdicionales.Visible Then
If LblDescuentoAdicional.Text.ToDecimal() > 0 Then
Dim TotalDescuento As Decimal = LblDescuentoAdicional.Text.ToDecimal() / (1D + TmpDT.MAX("PorcentajeIVA").ToString().ToDecimal())
Dim RowDescuentos As DataRow() = TmpDT.Select("Descuento > 0")
If RowDescuentos IsNot Nothing Then
Dim Row As DataRow = RowDescuentos(0)
Row("Descuento") = Row("Descuento").ToString().ToDecimal() + TotalDescuento
Dim TotalCalculableImpuestos As Decimal = (Row("Cantidad").ToString().ToDecimal() * Row("PU").ToString().ToDecimal()) - Row("Descuento").ToString().ToDecimal()
Row("ImporteIVA") = (TotalCalculableImpuestos * Row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
CalculaTotalesVenta(RecalcularTotalOriginal:=False)
'UpPS.Update()
'VALIDA EL CALCULO DE LOS DESCUENTOS
If (LblTotalOriginal.Text.ToDecimal() - LblDescuentoAdicional.Text.ToDecimal()) <> TxtTotal.Text.ToDecimal() Then
TmpDT = TmpDTError.Copy()
CalculaTotalesVenta(RecalcularTotalOriginal:=False)
Alert("Ocurrió un error al procesar los datos de la Venta. Los descuentos no coinciden con el importe final", TipoMensaje.MsgError)
Exit Sub
End If
End If
End If
End If
CreaObjetosVenta(TipoDoctoViejo:=TipoDoctoViejo)
If ObjFactura Is Nothing OrElse (ObjFactura.Cliente Is Nothing And Not CveEmpresaCRM > 0) Then
Alert("Ocurrió un error al procesar los datos de la Venta.", TipoMensaje.MsgError)
ObjFactura = Nothing
Exit Sub
End If
If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "Ant", "DPe") Then
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
If ObjFactura.SubTotal <= 0 Then
Alert("Es necesario especificar el importe en los conceptos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If ObjFactura.CveCliente > 0 Or CveEmpresaCRM > 0 Then
If TmpDT.Rows.Count > 0 Then
Dim ObjVentas As New ClsVentas()
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL())
Dim ObjOS As New ClsOS(ObjVentas.IniciaTransacSQL())
Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
Dim ObjClientes As New ClsClientes(ObjVentas.IniciaTransacSQL())
Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL())
Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL())
Dim ObjDocCliente As New ClsEdocumentacion(ObjVentas.IniciaTransacSQL())
Dim ObjGeneral As New ClsGenerales(ObjVentas.IniciaTransacSQL())
Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
'Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL())
ErrorList = New List(Of String)
MensajeAlert = New StringBuilder
'GUARDA VENTA
Dim TieneAnticipo As Boolean = False
Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo
Dim FolioFiscalRelacionado As String = ""
'If GVAnticipos.Rows.Count > 0 Then
' Dim actualindex As Integer = 0
' For Each row2 As GridViewRow In GVAnticipos.Rows
' If row2.FCCheckBox("Chk" & row2.RowIndex).Checked Then
' TieneAnticipo = True
' CveAnticipoPadre = row2.DataKey("CveVenta").ToEntero()
' CveAnticipo = CveAnticipoPadre
' 'CUANDO ES REFACTURACION DEBE RELACIONAR CON LA FACTURA REFACTURADA
' If NuevaFactura <> 1 Then
' ObjFactura.CveVentaRelacion = CveAnticipoPadre 'relaciona al anticipo
' ObjFactura.ImporteRelacion = row2.FCTextBox($"TxtAnticipo{actualindex}").Text.ToDecimal
' FolioFiscalRelacionado = row2.DataKey("FolioFiscal")
' ObjFactura.CveVentaPadre = row2.DataKey("CveVenta").ToEntero()
' Else
' ObjFactura.CveVentaRelacion = CveDevolucion
' End If
' End If
' actualindex = actualindex + 1
' Next
'End If
Dim EsNCAmortizacion As Boolean = False
Dim CveVentaAnterior As Integer = Me.CveVenta
Dim CveTimbreCartaPorte As Integer = -1
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjAcum, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjBancos, ObjOS,
ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion, CveAnticipoPadre:=CveAnticipoPadre)
'If ErrorList.Count = 0 AndAlso ChkEmitirCartaPorte.Checked AndAlso ObjFactura.TipoDocto = "Ing" Then
' CveTimbreCartaPorte = GuardarCartaPorte(ObjFactura, ObjGeneral, ObjClientes)
' If CveTimbreCartaPorte <= 0 Then
' ErrorList.Add("Ocurrió un error al registrar la carta porte")
' End If
'End If
'Agregamos las OCs a la tabla
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then
Dim CveVentaDetalle As Integer = 0
Dim CveOrdenCompraDetalle As Integer = 0
Dim Cantidad As Decimal = 0
For Each row As DataRow In TmpDT.Rows
Cantidad = row("Cantidad").ToString().ToDecimal
CveVentaDetalle = row("CveVentaDetalle").ToString().ToEntero()
CveOrdenCompraDetalle = row("CveOrdenCompraDetalle").ToString().ToEntero()
If Not ObjVentas.AgregarVentaOCDetalle(CveVentaDetalle, CveOrdenCompraDetalle, Cantidad) Then
ErrorList.Add("Ocurrió un Error al agregar el detalle de la Remision")
Exit For
End If
Next
End If
If Not String.IsNullOrEmpty(TipoDoctoViejo) Then
'SI VIENE DE UNA AUTORIZACION
If TipoDoctoViejo = "PA" Then
If Not ObjEventos.AddEventoBitacora(String.Format("Se generó una remisión en Folio: {1}", ObjFactura.CveVenta, ObjFactura.SerieFolio), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaAnterior) Then
ErrorList.Add("Ocurrió un error al agregar la bitacora de Póliza Virtual.")
End If
End If
End If
'SI ES REFACTURACION
Dim ObjNC As List(Of Object) = Nothing
If ErrorList.Count = 0 Then
If NuevaFactura = 1 Then
'SI YA ESTA MARCADA LA VENTA ANTERIOR
If DevolucionAlmacenNC = 2 Then
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
'MARCAR VENTA ANTERIOR
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
Else
'MARCA LO PENDIENTE A NIVEL DETALLE
Dim DtMovDetalles As DataTable = Nothing
If ObjInventario.GetSaldoVentaDetalle(CveDevolucion, UsuarioActual.CveEmpresa) Then
DtMovDetalles = ObjInventario.DtResultados.Copy()
Else
ErrorList.Add("No se pudo verificar los movimientos de almacen de la factura")
End If
'MARCAR VENTA ANTERIOR
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
If DtMovDetalles IsNot Nothing Then
Dim CantidadTotal As Decimal = 0
Dim TotalSalida As Decimal = 0
For Each Row As DataRow In DtMovDetalles.Rows
Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal()
Dim SaldoAlmacen As Decimal = Row("SaldoAlmacen").ToString().ToDecimal()
CantidadTotal += Cantidad
If SaldoAlmacen < 0 AndAlso Cantidad = Math.Abs(SaldoAlmacen) Then
TotalSalida += Math.Abs(SaldoAlmacen)
If Not ObjInventario.UpdateEstatusAlmacen(Row("CveVentaDetalleNueva").ToString().ToEntero(), 1) Then
ErrorList.Add("No se pudo actualizar el movimiento de almacen de la factura")
End If
End If
Next
'SI SE VERIFICA QUE TODO ESTA SURTIDO, SE MARCA TODA LA FACTURA
If CantidadTotal = TotalSalida Then
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
End If
End If
DtMovDetalles.Dispose()
End If
End If
End If
'SI ES AMORTIZACION 3.3
'Dim ListaNotasCreditoGeneradas As New List(Of Modelos.Factura)
Dim NCDescuento As Boolean = ((ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0) OrElse (ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0))
Dim SerieFolioNCProntoPago As String = ""
Dim CveVentaNCProntoPago As Integer = -1
''SOLO GENERAR NC POR DESCUENTO PRONTO PAGO SI EL PAGO ES DE CONTADO
'If ErrorList.Count = 0 AndAlso RBLPago.SelectedValue = "2" AndAlso ObjFactura.DescuentoProntoPago > 0 Then
' Dim ImportePagado As Decimal = DtPagos.SUMD("Importe")
' Dim ImporteRNC As Decimal = LblDescuentosRNC.Text.ToDecimal()
' If (ImportePagado + ImporteRNC + ObjFactura.DescuentoProntoPago) >= ObjFactura.Total Then
' Dim RespFacturaProntoPago As Modelos.MensajeProntoPago = GenerarNCProntoPago(ObjVentas.IniciaTransacSQL(), ObjClientes, ObjFactura)
' If RespFacturaProntoPago.ObjFacturaProntoPago Is Nothing OrElse RespFacturaProntoPago Is Nothing Then
' ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
' Else
' If RespFacturaProntoPago.Mensaje.CveVenta <= 0 OrElse RespFacturaProntoPago.Mensaje.TieneError Then
' ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
' Else
' CveVentaNCProntoPago = RespFacturaProntoPago.Mensaje.CveVenta
' SerieFolioNCProntoPago = RespFacturaProntoPago.Mensaje.SerieFolio
' ListaNotasCreditoGeneradas.Add(RespFacturaProntoPago.ObjFacturaProntoPago)
' End If
' End If
' Else
' ErrorList.Add("No se pudo generar la nota de crédito de pronto pago, no coiciden los pagos con el total a pagar de la factura")
' End If
'End If
If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ErrorList.Count = 0 AndAlso ObjFactura.TipoDocto = "Ing" Then
Dim RowVenta As DataRow = Nothing
If ObjVentas.GetVenta(ObjFactura.CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False) Then
RowVenta = ObjVentas.DtResultados.Rows(0)
Else
ErrorList.Add("No se pudieron validar los datos de la venta")
End If
If RowVenta IsNot Nothing Then
'SI FUE VENTA DE CONTADO VALIDA QUE SE HAYA PAGADO EN SU TOTALIDAD
If RowVenta("CondicionesPago").ToString().ToEntero() = 0 AndAlso RowVenta("Saldo").ToString().ToDecimal() > 0.01D Then
ErrorList.Add("La venta no fue pagada en su totalidad")
End If
Else
ErrorList.Add("No se pudieron validar los datos de la venta")
End If
End If
'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE
If ErrorList.Count = 0 Then
If ObjFactura.CveVenta > 0 And CveAlmacenExistenciasContrato > 0 And DdlTipoComprobante.SelectedValue = "Ing" Then
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
ErrorList.Add("No se pudo cancelar el movimiento de almacen de la Factura de consignación")
End If
End If
End If
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 Then
'ACTUALIZA VENTA COTIZACIÓN
If EraCotizacion = 1 And BtnEmitirImprimir.Text = "Facturar" Then
If Not ObjVentas.UpdateVentaCotizacion(ObjFactura.CveVenta, Request("CveVenta").ToEntero()) Then
ErrorList.Add("Ocurrió un error al actualizar la cotización")
End If
End If
'ACTUALIZA VENTAPADRE PEDIDO
If Request("DevPed").ToEntero() > 0 AndAlso ErrorList.Count = 0 Then
If Not ObjVentas.UpdateVentaCotizacion(Request("DevPed").ToEntero(), ObjFactura.CveVenta) Then
ErrorList.Add("Ocurrió un error al actualizar la devolución de pedido")
End If
End If
'ACTUALIZA LA COLUMNA CveVentaFacturada
If (Request("CveRemision") IsNot Nothing AndAlso ViewState("CveRemision").ToString().ToEntero() > 0) AndAlso (Request("Op") IsNot Nothing AndAlso Request("Op") = "Rem") AndAlso ErrorList.Count = 0 Then
If Not ObjVentas.UpdateVentaRemision(ViewState("CveRemision").ToString().ToEntero(), ObjFactura.CveVenta) Then
ErrorList.Add("Ocurrió un error al actualizar la remision")
End If
End If
'Agregamos las Cotizaciones a la tabla
If DtCotizacionesPS IsNot Nothing AndAlso DtCotizacionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then
Dim CveVentaDetalle As Integer = 0
Dim CveVentaDetallePadre As Integer = 0
Dim Cantidad As Decimal = 0
Dim CvePS As Integer = 0
Dim PU As Decimal = 0
For Each row As DataRow In DtCotizacionesPS.Rows
Cantidad = DtCotizacionTmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal
CvePS = DtCotizacionTmpDT.FiltroPrimeroValor("CvePS", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero()
PU = DtCotizacionTmpDT.FiltroPrimeroValor("PU", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToDecimal
CveVentaDetalle = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetalleCotizacion={row("CveVentaDetalle")}").ToEntero()
CveVentaDetallePadre = row("CveVentaDetalle").ToString().ToEntero()
If Not ObjVentas.AgregaCotizacionDetalle(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then
ErrorList.Add("Ocurrió un Error al agregar el detalle de la Cotización.")
End If
Next
End If
'Marcamos las ventas anteriores a febrero como surtidas - Ajuste Compu
If ErrorList.Count = 0 Then
If Not ObjVentas.MarcarRemisionesSinSurtir(ObjVentas.CveVenta) Then
ErrorList.Add("Ocurrió un Error al marcar la factura")
End If
End If
'If CveFactura > 0 AndAlso ErrorList.Count = 0 Then
' If Not ObjVentas.UpdateVentaFacturas(CveFactura, ObjVentas.CveVenta, UsuarioActual.CveEmpresa) Then
' ErrorList.Add("No se pudo actualizar la Factura")
' End If
'End If
'If CveCicloComercial > 0 AndAlso ErrorList.Count = 0 Then
' If Not ObjContr.CicloComercialUpdate(CveCicloComercial, True, UsuarioActual.CveEmpresa, CveVenta:=ObjFactura.CveVenta) Then
' ErrorList.Add("No se pudo actualizar ")
' End If
'End If
'MARCAR LA FACTURA ANTERIOR
If (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
If Me.ObjFacturaNC IsNot Nothing Then
If Me.ObjFacturaNC.CveEstatusRefacturacion = 4 AndAlso Not ObjVentas.UpdateEstatusVenta(ObjFacturaNC.CveVenta, ObjFacturaNC.CveEstatusFactura, UsuarioActual.CveEmpresa, CveEstatusRefacturacion:=5) Then
ErrorList.Add("No se actualizó el estatus de la factura anterior.")
End If
End If
End If
'ContPAQ El movimiento 1 es el de Venta
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
AutoConta = AutocontaMatriz(AutoConta)
If DdlTipoComprobante.SelectedValue.Contiene("Rem", "RNC", "Cot", "Ped", "Pd2", "PA") Then
AutoConta = False
End If
If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then
AutoConta = False
End If
If UsuarioActual.CveEmpresa = 140 Then
AutoConta = True
End If
Try
If AutoConta Then
If Not ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa) Then
ErrorList.Add("Ocurrió un error al contabilizar, pongase en contacto con soporte técnico")
End If
End If
Catch ex As Exception
ErrorList.Add("Ocurrió un error al contabilizar, pongase en contacto con soporte técnico")
OnError("Ocurrió un error al contabilizar la factura", ex)
End Try
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
ObjVentas.Commit()
ObjFactura.DtDetalle = TmpDT 'actualiza por cambios de pedimentos.
ObjFactura.Timbre = PreParaTimbre(ObjFactura)
Try
ViewState("CveVenta") = ObjFactura.CveVenta
If Request("CveEmbarqueManifiesto") IsNot Nothing AndAlso IsNumeric(Request("CveEmbarqueManifiesto")) AndAlso Request("CveEmbarqueManifiesto").ToEntero() > 0 Then
If ObjVentas.Embarque_ManifiestoUpvta(ObjFactura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Request("CveEmbarqueManifiesto").ToEntero()) Then
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al actualizar el embarque", ex)
End Try
Try
ViewState("CveVenta") = ObjFactura.CveVenta
If Request("CveOrdenProduccion") IsNot Nothing AndAlso IsNumeric(Request("CveOrdenProduccion")) AndAlso Request("CveOrdenProduccion").ToEntero() > 0 Then
If ObjVentas.AgroOrdenProduccionUpvta(ObjFactura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Request("CveOrdenProduccion").ToEntero()) Then
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al actualizar la orden de producción", ex)
End Try
Try
Dim DirectoriArchivoXML As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto) ' System.IO.Path.Combine()
If Not Directory.Exists(DirectoriArchivoXML) Then
Directory.CreateDirectory(DirectoriArchivoXML)
End If
Catch ex As Exception
OnError("Ocurrió un error al generar el directorio de xml", ex)
End Try
Dim SeTimbro As Boolean = False
Dim SeTimbroNC As Boolean = False
Dim EstatusSMS As Integer = 0
Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing
'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO
If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then
Dim DebeTimbrar As Boolean = True
If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then
'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72)
If LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0 Then
DebeTimbrar = False
End If
End If
If UsuarioActual.TienePermisoProceso(335) Then
DebeTimbrar = False
End If
DebeTimbrar = False
If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
'FACTURA INGRESO/EGRESO
Dim FM As New Modelos.FemsaFactura
Dim TmpDT7Eleven As New DataTable
Dim TmpDTComplementosTimbrado As New DataTable
Dim ObjTimbrado As New Timbrado
Try
'If AplicaFEMSA Then
' PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
'End If
If DebeTimbrar Then
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
End If
Catch ex As Exception
OnError("Ocurrió un error al generar el timbrado", ex)
End Try
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
Dim MsgErrorTimbrado As String = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
'If DebeTimbrar AndAlso SeTimbro AndAlso ListaNotasCreditoGeneradas IsNot Nothing AndAlso ListaNotasCreditoGeneradas.Count > 0 Then
' Try
' For Each NCGenerada As Modelos.Factura In ListaNotasCreditoGeneradas
' If NCGenerada.Timbre IsNot Nothing Then
' NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
' NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
' Dim ObjTimbradoNC As New Timbrado
' Dim TimbroNC As Boolean = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
' If Not TimbroNC Then
' Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
' End If
' ObjTimbradoNC = Nothing
' End If
' Next
' Catch ex As Exception
' OnError("Ocurrió un error al timbrar la NC.", ex)
' End Try
'End If
If Not SeTimbro Then
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
End If
'CANCELAR FACTURA ANTERIOR
Try
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
If Me.ObjFacturaNC IsNot Nothing AndAlso Me.ObjFacturaNC.CveEstatusFactura <> 5 Then
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al cancelar la factura anterior.", ex)
End Try
End If
End If
End If
'MENSAJE PRINCIPAL
MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.
", ObjFactura.TipoDocumento, ObjFactura.SerieFolio))
' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA
If SeTimbro Then
Dim ArchivoXML As String = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
If File.Exists(ArchivoXML) Then
MensajeAlert.AppendFormat("