Files
SIG/asmx/WS_PuntoVenta.asmx

1783 lines
78 KiB
Plaintext

<%@ WebService Language="VB" Class="WS_PuntoVenta" %>
Imports System.Data
Imports System.Web.Services
Imports Extensiones
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")>
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Public Class WS_PuntoVenta
Inherits System.Web.Services.WebService
Partial Public Class RespuestaWS
Public Property Respuesta As Integer
Public Property Descripcion As String
Public Property HuboError As Boolean = True
Public Property Datos As New DataTable("Resultados")
Public Property Datos2 As New DataTable("Resultados")
End Class
Partial Public Class Envio
Public Property Empresa As Empresa
Public Property Correo As String
Public Property Correos As String()
Public Property Asunto As String
Public Property Contenido As String
End Class
Partial Public Class ClsProductosServiciosWS
Public Property CvePS As Integer
Public Property CveClasificacion As Integer
Public Property CveUnidadMedida As Integer
Public Property Codigo As String
Public Property PS As String
Public Property Precio As Double
Public Property Oferta As Double
Public Property IVA As Double
Public Property RetIVA As Double
Public Property MargenGanancia As Double
Public Property AsientoContableVentas As Integer
Public Property AsientoContableCompras As Integer
Public Property AplicaParaConcepto As Boolean
Public Property Estado As Boolean
Public Property Fecha As Date
Public Property Usuario As String
Public Property CveEmpresa As Integer
End Class
Partial Public Class ClsClasificacionesWS
Public Property CveClasificacion As Integer
Public Property Clasificacion As Integer
Public Property CveEmpresa As Integer
End Class
Partial Public Class ClsMovimientosCajaWS
Public Property CveMovimiento As Integer
Public Property CveCorte As Integer
Public Property Importe As Double
Public Property Descripcion As String
Public Property TipoMovimiento As String
Public Sub New()
End Sub
Public Sub New(CveMovimiento As Integer, CveCorte As Integer, Importe As Double, Descripcion As String, TipoMovimiento As String)
Me.CveMovimiento = CveMovimiento
Me.CveCorte = CveCorte
Me.Importe = Importe
Me.Descripcion = Descripcion
Me.TipoMovimiento = TipoMovimiento
End Sub
End Class
Partial Public Class ClsMetodosPagoWS
Public Property CveMetodoPago As Integer
Public Property MetodoPago As String
Public Property Importe As Decimal
Public Sub New()
End Sub
Public Sub New(CveMetodoPago As Integer, MetodoPago As String)
Me.CveMetodoPago = CveMetodoPago
Me.MetodoPago = MetodoPago
End Sub
End Class
Partial Public Class ClsVta_BitacoraWS
Public Property CveBitacora As Integer
Public Property CveVenta As Integer
Public Property Fecha As DateTime
Public Property Observacion As String
Public Property CveUsuario As Integer
Public Sub New()
End Sub
Public Sub New(CveBitacora As Integer, CveVenta As Integer, Fecha As DateTime, Observacion As String, CveUsuario As Integer)
Me.CveVenta = CveVenta
Me.Fecha = Fecha
Me.Observacion = Observacion
Me.CveUsuario = CveUsuario
End Sub
End Class
Partial Public Class ClsVtaCortesWS
Public Property CveCorte As Integer
Public Property FechaInicial As DateTime
Public Property FechaFinal As DateTime
Public Property ImporteInicial As Double
Public Property ImporteFinal As Double
Public Property Diferencia As Double
Public Property Descripcion As String
Public Property Estatus As String
Public Property Usuario As String
Public Property UsuarioNombre As String
Public Property Vendido As Double
Public Property VendidoEfectivo As Double
Public Property Retirado As Double
Public Property Ingresado As Double
Public Property CveEmpresa As Integer
Public Property CortesDetalles As List(Of ClsVtaCortesDetallesWS)
Partial Public Class ClsVtaCortesDetallesWS
Public Property CveCorte As Integer
Public Property CveMetodoPago As Integer
Public Property Importe As Double
Public Sub New()
End Sub
Public Sub New(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double)
Me.CveCorte = CveCorte
Me.CveMetodoPago = CveMetodoPago
Me.Importe = Importe
End Sub
End Class
Public Sub New()
End Sub
Public Sub New(CveCorte As Integer, FechaInicial As DateTime, FechaFinal As DateTime, ImporteInicial As Double, ImporteFinal As Double, Descripcion As String, Estatus As String, Usuario As String, UsuarioNombre As String, Vendido As Double, VendidoEfectivo As Double, Retirado As Double, Ingresado As Double)
Me.CveCorte = CveCorte
Me.FechaInicial = FechaInicial
Me.FechaFinal = FechaFinal
Me.ImporteInicial = ImporteInicial
Me.ImporteFinal = ImporteFinal
Me.Descripcion = Descripcion
Me.Estatus = Estatus
Me.Usuario = Usuario
Me.UsuarioNombre = UsuarioNombre
Me.Vendido = Vendido
Me.VendidoEfectivo = VendidoEfectivo
Me.Retirado = Retirado
Me.Ingresado = Ingresado
End Sub
End Class
Partial Public Class ClsVtaVentasPagoWS
Public Property CveCorte As Integer
Public Property MetodoPago As String
Public Property Importe As Double
Public Sub New()
End Sub
Public Sub New(CveCorte As Integer, MetodoPago As String, Importe As Double)
Me.CveCorte = CveCorte
Me.MetodoPago = MetodoPago
Me.Importe = Importe
End Sub
End Class
Partial Public Class UsuarioWS
Public Property CveUsuario As Integer
Public Property Usuario As String
Public Property Contraseña As String
Public Property Nombre As String
Public Property CveRol As Integer
Public Property Rol As String
Public Property NombreEmpresa As String
Public Property CveEmpresa As Integer
Public Property Liga As String
Public Property Portal As Boolean = False
'Public Property Modulos As HybridDictionary
'Public Property Procesos As HybridDictionary
Public Property SeleccionoEmpresa As Boolean
Public Property CveSucursal As Integer
Public Property CveProveedor As Integer
Public Property CveCliente As Integer
Public Property CveSupervisor As Integer
Public Property CveCoordinador As Integer
Public Property CveProspecto As Integer
Public Property CveVendedor As Integer
Public Property EsRestaurant As Boolean
Public Property Referencia As String
Public Property EsSupervisorRH As Boolean
Public Property Empresa As Empresa = Nothing
Public Property ModoSimulacion As Boolean = False
Public Property NombreAbreviatura As String
End Class
' Public Class Empresa
' Public CveEmpresa As Integer
' Public Empresa As String
' Public Direccion As String
' Public NoExt As String
' Public NoInt As String
' Public Colonia As String
' Public Ciudad As String
' Public Estado As String
' Public CP As Integer
' Public RFC As String
' Public RegistroPatronal As String
' Public Telefono As String
' Public Contacto As String
' Public Mail As String
' Public TipoFacturacion As String
' Public ContraseñaKey As String
' Public ArchivoKey As String
' Public ArchivoCer As String
' Public ArchivoPfx As String
' Public BIUsuario As String
' Public BIContraseña As String
' Public Banner As String
' Public FacturaProduccion As Boolean
' Public FechaIng As Date
' Public CveUsuario As Integer
' Public SendMail As String
' Public SendMailPassword As String
' Public SendMailServer As String
' Public SendMailPuerto As Integer
' Public SendMailSSL As Boolean
' Public Usuario As String
' Public MostrarRetIVA As Boolean
' Public EjercicioActual As Integer
' Public PeriodoActual As Integer
' Public GralSoloProyecto As Boolean
' Public MetodoOC As Integer
' Public RequiereCentroCostos As Boolean
' Public Tipo_CentroCosto As Integer
' Public Property MostrarRetISR As Boolean
' Public Property Regimen As String
' Public Property EstatusFacturacion As Boolean
' Public Property Estatus As Boolean
' Public Property UsaContabilidad As Boolean
' Public Property UsaBancos As Boolean
' Public Property UsaVentas As Boolean
' Public Property UsaCompras As Boolean
' Public Property UsaCxC As Boolean
' Public Property UsaInventarios As Boolean
' Public Property UsaRH As Boolean
' Public Property UsaNomina As Boolean
' Public Property UsaOS As Boolean
' Public Property UsaAC As Boolean
' Public Property BDContPAQi As String
' Public Property ServerContPAQi As String
' Public Property UsrContPAQi As String
' Public Property PwdContPAQi As String
' Public Property Buzon_Mail As String
' Public Property Buzon_Server As String
' Public Property Buzon_Puerto As Integer
' Public Property Buzon_SSL As Boolean
' Public Property Buzon_USR As String
' Public Property Buzon_PWD As String
' Public Property Timbres As Integer
' Public Property Ruta As String
' Public Property IdCuentaIVAxTrasladar As Integer
' Public Property IdCuentaIVATrasladado As Integer
' Public Property IdCuentaPerdidaCambiaria As Integer
' Public Property IdCuentaGananciaCambiaria As Integer
' Public Property ContaContabilizacionNC As Integer
' Public Property PV_TerminalTipo As Integer
' 'Public Property Funcionalidades As HybridDictionary
' ' Public Function ValorFuncionalidad(CveFuncionalidad As Integer) As string
' ' Return if(Funcionalidades IsNot Nothing AndAlso Funcionalidades.Item(CveFuncionalidad) IsNot Nothing, Funcionalidades.Item(CveFuncionalidad).ToString,"")
' 'End Function
'End Class
Partial Public Class ClsVentaWS
Public CveVenta As Integer
Public CveVentaTerminal As Integer
Public TipoDocto As String
Public FolioFact As Integer
Public CveCliente As Integer
Public CveClienteSucursal As Integer
Public SubTotal As Decimal
Public Descuento As Decimal
Public Amortizacion As Decimal
Public IVA As Decimal
Public RetIVA As Decimal
Public RetISR As Decimal
Public Total As Decimal
Public CveMoneda As Integer
Public TipoCambio As Decimal
Public CveMetodoPago As Integer
Public CondicionesPago As Integer
Public FormaPago As Integer
Public FechaPago As DateTime
Public Fecha As DateTime
Public MotivoDescuento As String
Public Observaciones As String
Public FechaEjecucion As DateTime
Public CveVendedor As Integer
Public CveSucursalEjecucion As Integer
Public Alfa1 As String
Public Alfa2 As String
Public Alfa3 As String
Public Num1 As Double
Public Num2 As Double
Public Num3 As Double
Public Fech1 As String
Public Fech2 As String
Public Fech3 As String
Public CveUsuario As Integer
Public CveCorte As Integer
'Public CveMesa As Integer
Public NumeroPersonas As Integer
Public CveSubProyecto As Integer
Public CveEmpresa As Integer
Public Propina As Decimal
Public Detalle As List(Of ClsVentaDetalleWS)
Public MetodoPago As List(Of ClsMetodosPagoWS)
Public Bitacora As List(Of ClsVta_BitacoraWS)
Public Class ClsVentaDetalleWS
Public CveVenta As Integer
Public CvePS As Integer
Public Cantidad As Decimal
Public CveUnidadMedida As Integer
Public PU As Decimal
Public IVA As Decimal
Public TotalIVA As Decimal
Public Total As Decimal
Public Observaciones As String
Public Oferta As Decimal
Public PrecioFinal As Decimal
Public Descuento As Decimal
Public TipoDescuento As Integer
Public CveSubProyecto As Integer
Public EsPaquete As Boolean
Public PS As String
Public Codigo As String
Public Caracteristicas As List(Of ClsVentaDetalleCaracteristicaWS)
End Class
Public Class ClsVentaDetalleCaracteristicaWS
Public CveVentaDetalle As Integer
Public CvePS As Integer
Public CveOpcion As Integer
End Class
End Class
Partial Public Class ClsPrePolizaWS
Public CvePrepoliza As Integer
Public CvePrepolizaTerminal As Integer
Public Modulo As String
Public CveTipoPoliza As Integer
Public Cargos As Double
Public Abonos As Double
Public CveMoneda As Integer
Public Fecha As Date
Public NumeroPoliza As String
Public FechaConta As DateTime
Public IdPoliza As Integer
Public Estatus As Boolean
Public FechaIng As DateTime
Public CveUsuario As Integer
Public CveEmpresa As Integer
Public Detalle As List(Of ClsPrePolizaDetalleWS)
Public Class ClsPrePolizaDetalleWS
Public CvePrePolizaDetalle As Integer
Public CvePrePoliza As Integer
Public TipoMovto As Boolean
Public Importe As Double
Public Referencia As String
Public CveConceptoContable As Integer
Public Concepto As String
Public FechaVencimiento As DateTime
Public IdSegmentoNegocio As Integer
Public CveIE As Integer
Public CveVenta As Integer
Public CveCompra As Integer
Public CveSubProyecto As Integer
Public CveCliente As Integer
Public CveProveedor As Integer
Public CvePersonal As Integer
Public CveMovimientoAlmacen As Integer
Public CveActivoFijo As Integer
End Class
End Class
#Region "Empresas, Sucursales, Clientes, Monedas, UnidadesMedida, Vta_Promociones, Vta_PromocionesDetalle"
<WebMethod()>
Public Function GetEmpresa(CveEmpresa As Integer) As RespuestaWS
Dim objEmpresa As New ClsSisEmpresas
Dim Respuesta As New RespuestaWS
If objEmpresa.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
Respuesta.Datos = objEmpresa.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objEmpresa.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetSubProyectos(CveEmpresa As Integer) As RespuestaWS
Dim objProyecto As New ClsSubProyectos
Dim Respuesta As New RespuestaWS
If objProyecto.GetSubProyectos(CveEmpresa) Then
Respuesta.Datos = objProyecto.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objProyecto.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetSucursales(CveEmpresa As Integer) As RespuestaWS
Dim objProyecto As New ClsSubProyectos
Dim Respuesta As New RespuestaWS
If objProyecto.GetSubProyectos(CveEmpresa) Then
Respuesta.Datos = objProyecto.DtResultados
Respuesta.Datos.Columns(2).ColumnName = "CveSucursal"
Respuesta.Datos.Columns(3).ColumnName = "Sucursal"
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objProyecto.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetClientes(CveEmpresa As Integer) As RespuestaWS
Dim objClientes As New ClsClientes
Dim Respuesta As New RespuestaWS
If objClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
Respuesta.Datos = objClientes.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objClientes.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetGral_Folios(CveEmpresa As Integer) As RespuestaWS
Dim objFolios As New ClsGralFolios
Dim Respuesta As New RespuestaWS
If objFolios.GetFolios() Then
Respuesta.Datos = objFolios.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objFolios.Dispose()
Return Respuesta
End Function
'Candiddato a borrar
'COMENTADO IPP: CAMBIO LA FORMA DE USAR LAS PROMOCIONES | 2 NOVIEMBRE 2016
'<WebMethod()>
'Public Function GetVta_PromocionesDetalle(CvePS As Integer, Fecha As String, CveSucursal As Integer, CveEmpresa As Integer) As RespuestaWS
' Dim objPromocionesDetalle As New ClsVentas
' Dim Respuesta As New RespuestaWS
' If objPromocionesDetalle.GetPromocionesDetalle(-1, CvePS, Fecha, CveSucursal, CveEmpresa) Then
' Respuesta.Datos = objPromocionesDetalle.DtResultados
' Respuesta.Datos.TableName = "Resultados"
' Respuesta.HuboError = False
' Else
' Respuesta.Descripcion = "HUBO UN ERROR"
' End If
' objPromocionesDetalle.Dispose()
' Return Respuesta
'End Function
<WebMethod()>
Public Function GetVta_Promociones(Fecha As String, CveSubProyecto As Integer, CveEmpresa As Integer) As RespuestaWS
Dim objPromociones As New ClsVentas
Dim Respuesta As New RespuestaWS
If objPromociones.GetPromociones(-1, Fecha, -1, -1, 1, CveEmpresa, CveSubProyecto) Then
Respuesta.Datos = objPromociones.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPromociones.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetUnidadesMedida(CveEmpresa As Integer) As RespuestaWS
Dim objUnidadesMedida As New ClsUnidadesMedida
Dim Respuesta As New RespuestaWS
If objUnidadesMedida.GetUnidadesMedida(CveEmpresa) Then
Respuesta.Datos = objUnidadesMedida.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objUnidadesMedida.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetMonedas(CveEmpresa As Integer) As RespuestaWS
Dim objMonedas As New ClsMonedas
Dim Respuesta As New RespuestaWS
If objMonedas.GetMonedas() Then
Respuesta.Datos = objMonedas.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objMonedas.Dispose()
Return Respuesta
End Function
#End Region
#Region "ProductosServicios"
<WebMethod()>
Public Function GetProductosServicios(CvePS As Integer, CveClasificacion As Integer, Codigo As String, PS As String, CveEmpresa As Integer, CveSucursal As Integer) As RespuestaWS
Dim objPS As New ClsProductosServicios
Dim Respuesta As New RespuestaWS
If objPS.GetPS(CvePS, CveClasificacion, CveEmpresa, Codigo, PS:=PS, CveSubProyecto:=CveSucursal, pAplicaParaVenta:=1, pEstado:=1) Then
Respuesta.Datos = objPS.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
GuardaLog($"CvePS: {CvePS}, CveClasificacion: {CveClasificacion}, CveEmpresa: {CveEmpresa}, Codigo: {Codigo}, PS: {PS}, CveSubProyecto: {CveSucursal}, pAplicaParaVenta: {1}, pEstado: {1}")
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPS.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetClasificaciones(CveEmpresa As Integer) As RespuestaWS
Dim objClasificaciones As New ClsClasificaciones
Dim Respuesta As New RespuestaWS
If objClasificaciones.GetClasificaciones() Then
Respuesta.Datos = objClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " + CveEmpresa.ToString)
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objClasificaciones.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetCategorias(CveEmpresa As Integer) As RespuestaWS
Dim objCategorias As New ClsGenerales
Dim Respuesta As New RespuestaWS
If objCategorias.GetCategorias() Then
Respuesta.Datos = objCategorias.DtResultados.FiltraParametros("CveEmpresa = " + CveEmpresa.ToString)
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objCategorias.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetProductosServiciosEquivalencias(CvePS As Integer, CveEmpresa As Integer) As RespuestaWS
Dim objPS As New ClsProductosServicios
Dim Respuesta As New RespuestaWS
If objPS.GetPSEquivalencias(CvePS, CveEmpresa) Then
Respuesta.Datos = objPS.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPS.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetProductosServiciosCaracteristicas(CveEmpresa As Integer, CveSubProyecto As Integer) As RespuestaWS
Dim objPSCaracteristicas As New ClsGralProductosServiciosCaracteristicas
Dim Respuesta As New RespuestaWS
If objPSCaracteristicas.GetProductosServiciosCaracteristicas(CveEmpresa, CveSubProyecto) Then
Respuesta.Datos = objPSCaracteristicas.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPSCaracteristicas.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetProductosServiciosCaracteristicasOpciones(CveEmpresa As Integer, CveSubProyecto As Integer) As RespuestaWS
Dim objPSCaracteristicas As New ClsGralProductosServiciosCaracteristicas
Dim Respuesta As New RespuestaWS
If objPSCaracteristicas.GetProductosServiciosCaracteristicasOpciones(CveEmpresa, CveSubProyecto) Then
Respuesta.Datos = objPSCaracteristicas.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPSCaracteristicas.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetProductosServiciosPaquetes(CveEmpresa As Integer) As RespuestaWS
Dim objPSPaquetes As New ClsProductosServicios
Dim Respuesta As New RespuestaWS
If objPSPaquetes.GetPaqueteDetalle(-1, CveEmpresa) Then
Respuesta.Datos = objPSPaquetes.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objPSPaquetes.Dispose()
Return Respuesta
End Function
#End Region
#Region "Usuarios"
<WebMethod()>
Public Function GetUsuariosDetalle(CveUsuario As Integer) As UsuarioWS
Dim objUsuario As New ClsSisUsuarios
Dim objEmpresa As New ClsSisEmpresas
Dim Usuario As New UsuarioWS
If objUsuario.GetUsuariosDetalle(CveUsuario, -1) Then
With Usuario
.CveUsuario = objUsuario.CveUsuario
.Usuario = objUsuario.Usuario
.Contraseña = objUsuario.Contraseña
.Nombre = objUsuario.Nombre
.CveRol = objUsuario.CveRol
'.Rol =
'.NombreEmpresa = objUsuario.no
.CveEmpresa = objUsuario.CveEmpresa
'.Liga =
'.Portal =
'.Modulos As HybridDictionary
'.Procesos As HybridDictionary
'.SeleccionoEmpresa As Boolean
'.CveSucursal =
'.CveProveedor =
'.CveCliente =
'.CveSupervisor As Integer
'.CveCoordinador As Integer
'.CveProspecto As Integer
'.CveVendedor As Integer
'.Referencia As String
'.EsSupervisorRH As Boolean
'.Empresa As Empresa = Nothing
'.ModoSimulacion As Boolean = False
'.NombreAbreviatura As String
If objEmpresa.GetEmpresas(.CveEmpresa, "-1", "-1", "-1", "-1") Then
.Empresa = objEmpresa.Empresa
End If
End With
End If
objUsuario.Dispose()
objEmpresa.Dispose()
Return Usuario
End Function
<WebMethod()>
Public Function GetUsuariosRolesProcesos(Usuario As String, Contraseña As String, CveProceso As Integer) As Integer
Dim CveUsuario As Integer = -1
Dim objUsuarios As New ClsSisUsuarioAutenticacion
Dim objUsuario As New Usuario
objUsuario = objUsuarios.ValidaUsuario(Usuario, Encripta(Contraseña))
If objUsuario IsNot Nothing AndAlso objUsuario.TienePermisoProceso(CveProceso) Then
CveUsuario = objUsuario.CveUsuario
End If
objUsuarios.Dispose()
Return CveUsuario
End Function
<WebMethod()>
Public Function GetUsuarios(CveEmpresa As Integer) As RespuestaWS
Dim Respuesta As New RespuestaWS
Respuesta.HuboError = False
Using objUsuarios As New ClsSisUsuarios
If objUsuarios.GetUsuarios(-1) Then
Respuesta.Datos = objUsuarios.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0} AND Estatus = 1 ", CveEmpresa))
Respuesta.Datos.TableName = "Resultados"
Else
Respuesta.HuboError = True
Respuesta.Descripcion = "HUBO UN ERROR"
End If
End Using
Using objsubproy As New ClsSubProyectos
If objsubproy.GetSubProyectosUsuarios(CveEmpresa:=CveEmpresa) Then
Respuesta.Datos2 = objsubproy.DtResultados
Respuesta.Datos2.TableName = "Resultados"
End If
End Using
Return Respuesta
End Function
<WebMethod()>
Public Function GetProcesos() As RespuestaWS
Dim objProcesos As New ClsSisProcesos
Dim Respuesta As New RespuestaWS
If objProcesos.GetProcesos(-1) Then
Respuesta.Datos = objProcesos.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objProcesos.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetUsuariosProcesos(CveUsuario As Integer) As RespuestaWS
Dim objUsuariosProcesos As New ClsSisUsuarios
Dim Respuesta As New RespuestaWS
If objUsuariosProcesos.GetUsuariosProcesos(CveUsuario) Then
Respuesta.Datos = objUsuariosProcesos.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
Else
Respuesta.Descripcion = "HUBO UN ERROR"
End If
objUsuariosProcesos.Dispose()
Return Respuesta
End Function
#End Region
#Region "MetodosPago"
<WebMethod()>
Public Function GetMetodosPagos() As RespuestaWS
Dim objMetodoPago As New ClsVentas
Dim Respuesta As New RespuestaWS
If objMetodoPago.GetMetodosPago() Then
Respuesta.Datos = objMetodoPago.DtResultados
Respuesta.Datos.TableName = "Resultados"
Respuesta.HuboError = False
End If
objMetodoPago.Dispose()
Return Respuesta
End Function
#End Region
#Region "Ventas"
<WebMethod()>
Public Function AddVenta(ArregloVentas As ClsVentaWS()) As List(Of ListItem)
Dim MM As String = "AddVenta -- INFORMACION, ENTRO A AddVenta de WS_PuntoVenta"
MM.GuardaLog()
Dim Errores As Boolean = False
Dim CveVentas As New List(Of ListItem)
Dim TotalPagado As Decimal = 0
For Each objVenta As ClsVentaWS In ArregloVentas
Dim Fech1, Fech2, Fech3 As Date
If objVenta.Fech1 IsNot Nothing AndAlso objVenta.Fech1.Trim.Length > 0 AndAlso IsDate(objVenta.Fech1) Then Fech1 = objVenta.Fech1.Trim.ToDate
If objVenta.Fech2 IsNot Nothing AndAlso objVenta.Fech2.Trim.Length > 0 AndAlso IsDate(objVenta.Fech2) Then Fech2 = objVenta.Fech2.Trim.ToDate
If objVenta.Fech3 IsNot Nothing AndAlso objVenta.Fech3.Trim.Length > 0 AndAlso IsDate(objVenta.Fech3) Then Fech3 = objVenta.Fech3.Trim.ToDate
Dim objVentas As New ClsVentas()
Dim ObjConta As New ClsContabilidad(objVentas.IniciaTransacSQL())
Dim ObjPs As New ClsProductosServicios()
Dim ErrorDetalles As Boolean = False
Dim ErrorMovtosVentas As Boolean = False
Dim ErrorMovtosDSV As Boolean = False
Dim ErrorMovtosCxC As Boolean = False
Dim ErrorMovtosTrasladoIVA As Boolean = False
Dim CvePrePoliza As Integer = 0
Try
If objVenta.CveVenta = 0 Then
objVenta.Amortizacion = 0
If objVentas.GetVentaTerminal(objVenta.CveVentaTerminal, objVenta.Fecha, objVenta.CveSubProyecto, objVenta.CveEmpresa) Then
CvePrePoliza = ObjConta.AddPrePolizas("Vta", 4, objVenta.Total, objVenta.Total, objVenta.CveMoneda, objVenta.Fecha, "Punto de Venta addVenta", objVenta.CveUsuario, objVenta.CveEmpresa)
If objVentas.DtResultados.Rows.Count = 0 Then
If objVenta.CveEmpresa = 1 Then
If objVenta.CveSubProyecto <= 0 Then
objVenta.CveSubProyecto = 10430
End If
If objVenta.FolioFact.ToString.Contiene("", "-1", "0") Then
objVenta.FolioFact = getFolio("Rem", objVenta.CveEmpresa, objVenta.CveSubProyecto).ToEntero
End If
End If
If objVentas.AddVenta(objVenta.TipoDocto, objVenta.FolioFact, objVenta.CveCliente, objVenta.CveClienteSucursal,
objVenta.SubTotal, objVenta.Descuento, objVenta.Amortizacion, objVenta.IVA, objVenta.RetIVA, objVenta.RetISR,
objVenta.Total, objVenta.CveMoneda, objVenta.TipoCambio, objVenta.CveMetodoPago, objVenta.CondicionesPago,
objVenta.FormaPago, ClsPaginas.NowADS(), objVenta.Fecha, objVenta.MotivoDescuento, objVenta.Observaciones, If(objVenta.FechaEjecucion < MinFecha, Now, objVenta.FechaEjecucion),
objVenta.CveVendedor, If(objVenta.Alfa1 IsNot Nothing, objVenta.Alfa1, ""), If(objVenta.Alfa2 IsNot Nothing, objVenta.Alfa2, ""), If(objVenta.Alfa3 IsNot Nothing, objVenta.Alfa3, ""), objVenta.Num1,
objVenta.Num2, objVenta.Num3, Fech1, Fech2, Fech3, objVenta.CveCorte, If(objVenta.NumeroPersonas > 255, 255, objVenta.NumeroPersonas), CvePrePoliza,
objVenta.CveUsuario, objVenta.CveEmpresa, objVenta.Propina, objVenta.CveVentaTerminal, CveSubProyecto:=objVenta.CveSubProyecto, CveSubProyectoEjecucion:=objVenta.CveSubProyecto, Vigencia:=Now) Then
objVenta.CveVenta = objVentas.CveVenta
'Ingresar los detalles
If objVenta.CveEmpresa = 1 Then
GuardaLog($"objVenta.Detalle {objVenta.Detalle.Count}")
End If
For Each Detalle As ClsVentaWS.ClsVentaDetalleWS In objVenta.Detalle
If objVentas.AddVentaDetalle(objVentas.CveVenta, Detalle.CvePS, Detalle.Cantidad, Detalle.CveUnidadMedida, Detalle.PU, Detalle.IVA, Detalle.Total, Detalle.Observaciones, Detalle.Descuento, Detalle.TipoDescuento, Detalle.CveSubProyecto, -1, IEPS:=0) Then
'Ingresar las caracteristicas del detalle de la venta
For Each Caracteristica As ClsVentaWS.ClsVentaDetalleCaracteristicaWS In Detalle.Caracteristicas
If objVentas.AddVentaDetalleCaracteristica(objVentas.CveVentaDetalle, Caracteristica.CvePS, Caracteristica.CveOpcion) = False Then
'Error al ingresar las caracteristicas del detalle de la venta
Errores = True
Exit For
End If
Next
Else
'Error al ingresar el detalle de la venta
ErrorDetalles = True
Exit For
End If
Next
'Ingresar Inventario Modificado por Charlie
'Dim ObjInv As New ClsInventarios(objVentas.IniciaTransacSQL)
'Dim CveInvMovimiento As Integer = ObjInv.AddMovimiento(6, 3, objVenta.CveMoneda, objVenta.Fecha, -1, objVenta.CveUsuario, objVenta.CveEmpresa, -1, objVenta.CveVenta, -1, -1)
'If CveInvMovimiento > 0 Then
' For Each Detalle As ClsVentaWS.ClsVentaDetalleWS In objVenta.Detalle
' If (Detalle.EsPaquete) Then
' If ObjPs.GetPaqueteDetalle(Detalle.CvePS) Then
' Dim contador As Integer = 0 'Declaramos el contador para manejar las filas
' For Each Row As DataRow In ObjPs.DtResultados.Rows
' If Not ObjInv.AddMovimientoDetalle(CveInvMovimiento, ObjPs.DtResultados.Rows(contador)("Cantidad").ToString.ToEntero, ObjPs.DtResultados.Rows(contador)("CveUnidadMedida").ToString.ToEntero, ObjPs.DtResultados.Rows(contador)("CvePS").ToString.ToEntero, ObjPs.DtResultados.Rows(contador)("Precio").ToString.ToDouble, -1) Then
' ErrorDetalles = True
' End If
' contador += 1
' Next
' Else
' ErrorDetalles = True
' End If
' Else
' If Not ObjInv.AddMovimientoDetalle(CveInvMovimiento, Detalle.Cantidad, Detalle.CveUnidadMedida, Detalle.CvePS, Detalle.PU, -1) Then
' ErrorDetalles = True
' End If
' End If
' Next
'Else
' Errores = True
'End If
If Errores = False And ErrorDetalles = False Then
'Ingresar los metodos de pago
'si el registro va correcto y no hay errores
For Each MetodoPago As ClsMetodosPagoWS In objVenta.MetodoPago
If MetodoPago.Importe > 0 Then
TotalPagado = TotalPagado + MetodoPago.Importe
If objVentas.AddVta_VentaPago(objVenta.CveVenta, MetodoPago.CveMetodoPago, MetodoPago.Importe) = False Then
'Error al ingresar el detalle de la venta
Errores = True
Exit For
End If
End If
Next
End If
If Errores = False And ErrorDetalles = False Then
'Ingresar los registros de bitacora
If objVenta.Bitacora.Count > 0 Then
For Each Bitacora As ClsVta_BitacoraWS In objVenta.Bitacora
If objVentas.AddVta_Bitacora(objVenta.CveVenta, Bitacora.Fecha, Bitacora.Observacion, Bitacora.CveUsuario) = False Then
'Error al ingresar el detalle de la venta
Errores = True
Exit For
End If
Next
End If
End If
'Ingresar PrePoliza si no esta pagada
If Errores = False And ErrorDetalles = False And TotalPagado < objVenta.Total Then
Dim CveIE As Integer = -1
Dim CveConceptoAfectacion As Integer = 1 'Cliente
Dim CveConceptoAntCli As Integer = 3 'Anticipo Cliente
Dim CveConceptoVenta As Integer = 4 'Venta
Dim CveConceptoCanAnt As Integer = 11 'Cancelacion Anticipos
Dim CveConceptoDSV As Integer = 12 ' DSV
Dim CveConceptoIVA As Integer = 13 'IVA Trasladado
Dim CveConceptoRetIVA As Integer = 8 'Ret IVA
Dim CveConceptoRetISR As Integer = 9 'Ret ISR
If CvePrePoliza > 0 Then
Dim TipoMovimientoVenta As Boolean = True
Dim TipoMovimientoImpuestos As Boolean = False
Dim ImporteMov As Decimal
'Se agregan los movimientos de la Venta
'If DT.Rows.Count > 0 Then
'Se agrega movimiento separado por la cuenta de ventas (ER)
' For Each Row As DataRow In DT.Rows
ImporteMov = objVenta.SubTotal
' FIXME OIC
'Dim CveClasificacion_04 As Integer = -1
'If ImporteMov <> 0 Then
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoVenta, ImporteMov, ImporteMov, CveConceptoVenta, " ", " ", CveVenta:=objVenta.CveVenta, CveCliente:=objVenta.CveCliente, CveIE:=CveIE, CveSubProyecto:=objVenta.CveSubProyecto, CveClasificacion:=CveClasificacion_04) Then
' ErrorMovtosVentas = True
' End If
'End If
'' Next
''Se agregan los DSV DESCUENTOS
'ImporteMov = objVenta.Descuento
'If ImporteMov <> 0 Then
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoVenta, ImporteMov, ImporteMov, CveConceptoDSV, " ", " ", CveVenta:=objVenta.CveVenta, CveCliente:=objVenta.CveCliente, CveIE:=CveIE) Then
' ErrorMovtosDSV = True
' End If
'End If
''End If
''Se agregan las CxC
'ImporteMov = objVenta.Total - TotalPagado
'If ImporteMov <> 0 Then
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoVenta, ImporteMov, ImporteMov, CveConceptoAfectacion, " ", " ", CveVenta:=objVenta.CveVenta, CveCliente:=objVenta.CveCliente, CveIE:=CveIE) Then
' ErrorMovtosCxC = True
' End If
'End If
''Si hubo un pago agregarlo
'ImporteMov = TotalPagado
'If ImporteMov <> 0 Then
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimientoVenta, ImporteMov, ImporteMov, 2, " ", " ", CveVenta:=objVenta.CveVenta, CveCliente:=objVenta.CveCliente, CveIE:=CveIE) Then
' ErrorMovtosCxC = True
' End If
'End If
''Se agregan el Traslado de IVA
'ImporteMov = objVenta.IVA
'If ImporteMov <> 0 Then
' Dim PorcentajeImpuesto As Decimal = 0
' If objVenta.SubTotal > 0 Then
' PorcentajeImpuesto = (objVenta.IVA / objVenta.SubTotal)
' End If
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoVenta, ImporteMov, ImporteMov, CveConceptoIVA, " ", " ", CveVenta:=objVenta.CveVenta, CveCliente:=objVenta.CveCliente, CveIE:=CveIE, PorcentajeImpuesto:=PorcentajeImpuesto) Then
' ErrorMovtosTrasladoIVA = True
' End If
'End If
End If
End If
Else
Errores = True
End If
Else
objVentas.CveVenta = objVentas.DtResultados.Rows(0)("CveVenta").ToString.ToEntero
MM = "AddVenta -- INFORMACION, LA VENTA YA EXISTE EN LA BASE DE DATOS"
MM.GuardaLog()
End If
Else
Errores = True
End If
Else
objVentas.CveVenta = objVenta.CveVenta
'Ingresar los metodos de pago
'si el registro va correcto y no hay errores
objVentas.RemoveVta_VentaPago(objVenta.CveVenta, -1)
For Each MetodoPago As ClsMetodosPagoWS In objVenta.MetodoPago
If MetodoPago.Importe > 0 Then
If objVentas.AddVta_VentaPago(objVenta.CveVenta, MetodoPago.CveMetodoPago, MetodoPago.Importe) = False Then
'Error al ingresar el detalle de la venta
Errores = True
Exit For
End If
End If
Next
End If
Catch ex As Exception
Errores = True
End Try
If Errores OrElse ErrorDetalles OrElse ErrorMovtosVentas OrElse ErrorMovtosDSV OrElse ErrorMovtosCxC OrElse ErrorMovtosTrasladoIVA Then
objVentas.RollBack()
CveVentas.Add(New ListItem(objVenta.CveVentaTerminal.ToString, "-1"))
Else
objVentas.Commit()
CveVentas.Add(New ListItem(objVenta.CveVentaTerminal.ToString, objVentas.CveVenta.ToString))
End If
objVentas.Dispose()
ObjConta.Dispose()
Next
Return CveVentas
End Function
Private Function getFolio(TipoDoctoConsulta As String, CveEmpresa As Integer, CvesubProyecto As Integer) As String
Dim Respuesta As String = "-1"
Dim ObjFolios As New ClsGralFolios()
If ObjFolios.GetFolios(TipoDoctoConsulta, CveEmpresa) Then
GuardaLog($" GetFolios ok {ObjFolios.DtResultados.Rows.Count} . CvesubProyecto = {CvesubProyecto} .")
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", CvesubProyecto))
If DT.Rows.Count > 0 Then
Respuesta = DT.Rows(0)("FActual").ToString()
End If
DT.Dispose()
End If
ObjFolios.Dispose()
GuardaLog($" Folio Rem {Respuesta} .")
Return Respuesta
End Function
#End Region
#Region "Cortes"
<WebMethod()>
Public Function GetVtaCortes(FechaI As String, FechaF As String, CveUsuario As Integer, CveEmpresa As Integer, Finalizado As Integer) As List(Of ClsVtaCortesWS)
Dim objPV As New ClsPuntoVenta
Dim objVtaCortes As New List(Of ClsVtaCortesWS)
If (objPV.GetVta_Cortes(FechaI, FechaF, CveUsuario, -1, CveEmpresa, Finalizado) = True) Then
For Each Row As DataRow In objPV.DtResultados.Rows
objVtaCortes.Add(New ClsVtaCortesWS(Row("CveCorte").ToString.ToEntero, Row("FechaInicial").ToString.ToDateTime, If(IsDate(Row("FechaFinal")), Row("FechaFinal").ToString.ToDateTime, New DateTime), Row("ImporteInicial").ToString.ToDouble, If(Not IsDBNull(Row("ImporteFinal")), Row("ImporteFinal").ToString.ToDouble, 0), Row("Descripcion").ToString(), Row("Estatus").ToString, Row("Usuario").ToString, Row("UsuarioNombre").ToString, Row("Vendido").ToString.ToDouble, Row("VendidoEfectivo").ToString.ToDouble, Row("Retirado").ToString.ToDouble, Row("Ingresado").ToString.ToDouble))
Next
End If
objPV.Dispose()
Return objVtaCortes
End Function
'<WebMethod()>
'Public Function GetVta_MovimientosCajas(CveCorte As Integer, TipoMovimiento As Integer) As List(Of ClsMovimientosCajaWS)
' Dim objPV As New ClsPuntoVenta()
' Dim objMovimientosCaja As New List(Of ClsMovimientosCajaWS)
' If objPV.GetVta_MovimientosCajas(CveCorte, TipoMovimiento) Then
' For Each Row As DataRow In objPV.DtResultados.Rows
' objMovimientosCaja.Add(New ClsMovimientosCajaWS(Row("CveMovimiento").ToString.ToEntero, Row("CveCorte").ToString.ToEntero, Row("Importe").ToString.ToEntero, Row("Descripcion").ToString, Row("TipoMovimiento").ToString))
' Next
' End If
' objPV.Dispose()
' Return objMovimientosCaja
'End Function
<WebMethod()>
Public Function AddVta_MovimientosCajas(CveCorte As Integer, CveUsuario As Integer, Importe As Double, Descripcion As String, TipoMovimiento As Integer, Fecha As DateTime) As Integer
Dim objPV As New ClsPuntoVenta()
Dim CveMovimiento As Integer
If objPV.AddVta_MovimientosCajas(CveCorte, CveUsuario, Importe, Descripcion, TipoMovimiento, Fecha) Then
CveMovimiento = objPV.CveMovimiento
End If
objPV.Dispose()
Return CveMovimiento
End Function
<WebMethod()>
Public Function AddVtaCortes(FechaInicial As DateTime, ImporteInicial As Decimal, CveUsuario As Integer, Descripcion As String, CveEmpresa As Integer) As Integer
Dim objPV As New ClsPuntoVenta()
Dim CveCorte As Integer
If objPV.AddVtaCortes(FechaInicial, ImporteInicial, CveUsuario, Descripcion, -1, CveEmpresa) Then
CveCorte = objPV.CveCorte
End If
objPV.Dispose()
Return CveCorte
End Function
<WebMethod()>
Public Function AddVtaCortesDetalles(CveCorte As Integer, CveMetodoPago As Integer, Importe As Double) As Boolean
Dim Retorno As Boolean = False
Dim objPV As New ClsPuntoVenta()
If objPV.AddVtaCortesDetalles(CveCorte, CveMetodoPago, Importe) Then
Retorno = True
End If
objPV.Dispose()
Return Retorno
End Function
<WebMethod()>
Public Function PruebaMail() As Boolean
EnviarCorreo(3246, 61)
Return True
End Function
<WebMethod()>
Public Function UpdateVtaCortes(VtaCorte As ClsVtaCortesWS) As Boolean
Dim objPV As New ClsPuntoVenta()
Dim Respuesta As Boolean = False
objPV.IniciaTransacSQL()
If objPV.UpdateFinalizadoVtaCortes(VtaCorte.CveCorte, VtaCorte.ImporteFinal, VtaCorte.Diferencia, VtaCorte.FechaFinal, VtaCorte.CveEmpresa) Then
Respuesta = True
End If
If Respuesta = True Then
For Each CorteDetalle As ClsVtaCortesWS.ClsVtaCortesDetallesWS In VtaCorte.CortesDetalles
If Not objPV.AddVtaCortesDetalles(CorteDetalle.CveCorte, CorteDetalle.CveMetodoPago, CorteDetalle.Importe) Then
Respuesta = False
Exit For
End If
Next
End If
If Respuesta = True Then
objPV.Commit()
'Enviar correo de corte de turno
EnviarCorreo(VtaCorte.CveCorte, VtaCorte.CveEmpresa)
' Dim cuenta As Integer = GetCuenta(2090)
Else
objPV.RollBack()
End If
objPV.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetVentasPagoGet(CveCorte As Integer, CveEmpresa As Integer) As List(Of ClsVtaVentasPagoWS)
Dim objPV As New ClsPuntoVenta
Dim objVentasPago As New List(Of ClsVtaVentasPagoWS)
' Dim Respuesta As String
If objPV.GetVta_VentasPago(CveCorte, CveEmpresa) Then
For Each Row As DataRow In objPV.DtResultados.Rows
objVentasPago.Add(New ClsVtaVentasPagoWS(CveCorte, Row("MetodoPago").ToString, Row("Importe").ToString.ToDouble))
Next
End If
objPV.Dispose()
Return objVentasPago
End Function
'<WebMethod()>
'Public Function GetCuenta(CveSucursal As Integer) As Integer
' Dim objSU As New ClsSucursales
' Dim Cuenta As Integer
' 'Cuenta = objSU.GetCuenta(CveSucursal)
' objSU.Dispose()
' Return Cuenta
'End Function
<WebMethod()>
Public Function AddBancosIE(Importe As Decimal, Moneda As Integer, Fecha As Date, CveUsuario As Integer, CveEmpresa As Integer, Cuenta As Integer, Comprobante As String, Opcion As String) As Boolean
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim Folio As Long
Dim Banco As New ClsBancos
Dim Respuesta As Boolean = False
Dim CveIE As Integer
Dim MsgError As String = ""
Dim CveConceptoContable As Integer = 4
Dim CveConceptoCompra As Integer = 30
Dim CIF As Decimal = 0
Dim CvePlantillaPoliza As Integer = 4
Dim CveTipoPoliza As Integer = 1
Dim CvePrePoliza As Integer = 0
Dim CveTipoTransaccion As Integer = 4
Try
CvePrePoliza = ObjMov.AddPrePolizas("Banc", CvePlantillaPoliza, Importe, Importe, Moneda, Fecha, "Punto de venta IE", CveUsuario, CveEmpresa)
'valida prepoliza
If CvePrePoliza > 0 Then
Folio = Banco.GetNextFolio(Cuenta, CveTipoTransaccion)
Banco.Dispose()
CveIE = ObjIE.AddBancos_IE(Cuenta, CveTipoTransaccion, Fecha, Folio.ToString, "", Importe, Moneda,
0, Opcion, "", False, False, -1, CvePrePoliza, "pdf", CveUsuario, CveEmpresa)
If CveIE > 0 Then
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Importe, Importe, CveConceptoContable, "", " ", CveIE:=CveIE) Then
Dim IVA As Decimal = 0
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Importe - IVA - CIF, Importe - IVA - CIF, CveConceptoCompra, "", " ", CveIE:=CveIE) Then
Else
MsgError = "no se pudo insertar el detalle de la póliza2"
End If
Else
MsgError = "no se pudo insertar el detalle de la póliza"
End If
End If
End If
ObjIE.Commit()
Respuesta = True
Catch ex As Exception
Respuesta = False
ObjIE.RollBack()
End Try
ObjMov.Dispose()
ObjIE.Dispose()
Return Respuesta
End Function
#End Region
#Region "Vendedores"
<WebMethod()>
Public Function GetVendedores(CveEmpresa As Integer) As RespuestaWS
Dim objVend As New ClsVtaVendedores
Dim Respuesta As New RespuestaWS
If objVend.GetVendedores(CveEmpresa) Then
Respuesta.Datos = objVend.DtResultados '.FiltraParametros(String.Format("CveVendedor={0}", CveEmpresa))
Respuesta.Datos.TableName = "Vendedores"
Respuesta.HuboError = False
End If
objVend.Dispose()
Return Respuesta
End Function
#End Region
#Region "Mesas"
'<WebMethod()>
'Public Function GetMesas(CveEmpresa As Integer) As RespuestaWS
' Dim objVent As New ClsVentas
' Dim Respuesta As New RespuestaWS
' If objVent.GetMesas(CveEmpresa) Then
' Respuesta.Datos = objVent.DtResultados '.FiltraParametros(String.Format("CveVendedor={0}", CveEmpresa))
' Respuesta.Datos.TableName = "Mesas"
' Respuesta.HuboError = False
' End If
' objVent.Dispose()
' Return Respuesta
'End Function
#End Region
#Region "Inventario"
<WebMethod()>
Public Function GetInv_Almacenes(CveEmpresa As Integer) As RespuestaWS
Dim objInventario As New ClsInventarios
Dim Respuesta As New RespuestaWS
If objInventario.GetAlmacenes(-1, -1, CveEmpresa, -1) Then
Respuesta.Datos = objInventario.DtResultados.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
Respuesta.Datos.TableName = "Almacenes"
Respuesta.HuboError = False
End If
objInventario.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetInv_Conceptos() As RespuestaWS
Dim objInventario As New ClsInventarios
Dim Respuesta As New RespuestaWS
If objInventario.GetConceptos() Then
Respuesta.Datos = objInventario.DtResultados '.FiltraParametros(String.Format("CveVendedor={0}", CveEmpresa))
Respuesta.Datos.TableName = "Inv_Conceptos"
Respuesta.HuboError = False
End If
objInventario.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetInv_SeccionesAlmacenes(CveEmpresa As Integer) As RespuestaWS
Dim objInventario As New ClsInventarios
Dim Respuesta As New RespuestaWS
If objInventario.GetSeccionesAlmacenes(CveEmpresa, -1) Then
Respuesta.Datos = objInventario.DtResultados '.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
Respuesta.Datos.TableName = "Inv_SeccionesAlmacenes"
Respuesta.HuboError = False
End If
objInventario.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetInv_TiposAlmacenes(CveEmpresa As Integer) As RespuestaWS
Dim objInventario As New ClsInventarios
Dim Respuesta As New RespuestaWS
If objInventario.GetTiposAlmacenes() Then
Respuesta.Datos = objInventario.DtResultados.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
Respuesta.Datos.TableName = "Inv_TiposAlmacenes"
Respuesta.HuboError = False
End If
objInventario.Dispose()
Return Respuesta
End Function
<WebMethod()>
Public Function GetInv_Movimientos(CveEmpresa As Integer) As RespuestaWS
Dim objInventario As New ClsInventarios
Dim Respuesta As New RespuestaWS
If objInventario.GetMovimientos(-1, -1, -1, CveEmpresa) Then
Respuesta.Datos = objInventario.DtResultados.FiltraParametros("CveMovimientoTerminal IS NULL")
Respuesta.Datos.TableName = "Inv_Movimientos"
For Each Row As DataRow In Respuesta.Datos.Rows
If objInventario.GetMovimientosDetalle(Row("CveMovimiento").ToString.ToEntero, CveEmpresa) Then
If objInventario.DtResultados.Rows.Count > 0 Then
Respuesta.Datos2.Merge(objInventario.DtResultados)
End If
End If
Next
Respuesta.HuboError = False
End If
objInventario.Dispose()
Return Respuesta
End Function
#End Region
#Region "Contabilidad"
'<WebMethod()> _
'Public Function GetConta_ConceptosContables() As RespuestaWS
' Dim objConta As New ClsContabilidad
' Dim Respuesta As New RespuestaWS
' If objConta.GetConta_ConceptosContables() Then
' Respuesta.Datos = objConta.DtResultados
' Respuesta.Datos.TableName = "Conta_ConceptosContables"
' Respuesta.HuboError = False
' End If
' objConta.Dispose()
' Return Respuesta
'End Function
'<WebMethod()> _
'Public Function AddPrePolizas(ArregloPrePolizas As ClsPrePolizaWS()) As List(Of ListItem)
' Dim Errores As Boolean = False
' Dim CvePrePolizas As New List(Of ListItem)
' Dim CvePrePoliza As Integer
' Dim objConta As New ClsContabilidad
' For Each objPrepoliza As ClsPrePolizaWS In ArregloPrePolizas
' objConta.IniciaTransacSQL()
' If Errores = False Then
' objConta.Commit()
' CvePrePolizas.Add(New ListItem(objPrepoliza.CvePrepolizaTerminal.ToString, CvePrePoliza.ToString))
' Else
' objConta.RollBack()
' CvePrePolizas.Add(New ListItem(objPrepoliza.CvePrepolizaTerminal.ToString, "-1"))
' End If
' Next
' objConta.Dispose()
' Return CvePrePolizas
'End Function
#End Region
#Region "ENVIO CORREO"
Protected Sub EnviarCorreo(CveCorte As Integer, CveEmpresa As Integer)
Dim Body As String ''GlobalDTUsuarios(CveUsuario)(0)("correo").ToString
Dim Correo As String = If(CveEmpresa = 61, "ariel@grupoabt.mx", "rene.molina@gmail.com")
Dim Correos() As String = If(CveEmpresa = 61, {"roberto@grupoabt.mx", "isaac@grupoabt.mx", "grisey@grupoabt.mx"}, {"julian@adsistemas.mx", "jonaslopez@gmail.com"})
'Dim Correo As String = If(CveEmpresa = 61, "charlie.cuchm@gmail.com", "charlie.cuchm@gmail.com")
'Dim Correos() As String = If(CveEmpresa = 61, {"charlie.cuchm@gmail.com"}, {"charlie.cuchm@gmail.com", "charlie.cuchm@gmail.com"})
Dim Sucursal As String = ""
Try
Body = GeneraCorreo(CveCorte, CveEmpresa, Sucursal, "")
Dim Empresa As Empresa = Nothing
Dim ObjEmpresa As New ClsSisEmpresas()
If ObjEmpresa.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
Empresa = ObjEmpresa.Empresa
'Empresa.Ruta = String.Format("{0}Empresas\{1}\", ModExtensiones.DirectorioBaseEmpresas, CveEmpresa)
End If
ObjEmpresa.Dispose()
Dim Asunto As String = String.Format("SIG. Corte de Turno de: {0}", Sucursal)
Dim Hilo As New System.Threading.Thread(AddressOf MandaCorreo)
Dim Parametros(3) As Object
Parametros(0) = Empresa
Parametros(1) = Correo
Parametros(2) = Asunto
Parametros(3) = Body
Dim Env As New Envio
Env.Empresa = Empresa
Env.Correos = Correos
Env.Correo = Correo
Env.Asunto = Asunto
Env.Contenido = Body
Hilo.Start(Env)
' Alert("Se enviara correo por cambio Modificacion")
Catch ex As Exception
OnError("Ocurrió error al mandar MAIL", ex)
End Try
End Sub
Private Sub MandaCorreo(Data As Object)
Dim Env As Envio = CType(Data, Envio)
Dim Empresa As Empresa = Env.Empresa
Dim Correo As String = Env.Correo
Dim Asunto As String = Env.Asunto
Dim Body As String = Env.Contenido
Dim Correos() As String = Env.Correos
Dim Mail As New ClsSisMail()
Mail.SendMail(Empresa, Correo, Asunto, Body)
End Sub
Private Function GeneraCorreo(CveCorte As Integer, CveEmpresa As Integer, ByRef Sucursal As String, Opciones As String) As String
Dim strBody As New StringBuilder
'Obtener datos del corte de turno
Dim objPV As New ClsPuntoVenta
Dim strDetalle As New StringBuilder
Dim strProductos As New StringBuilder
Dim VendidoEfectivo As Double = 0
If objPV.GetVta_Cortes("-1", "-1", -1, CveCorte, CveEmpresa, -1) Then
If objPV.CveCorte > 0 Then
Sucursal = objPV.Sucursal
If objPV.GetVta_CortesDetalles(CveCorte) Then
For Each dr As DataRow In objPV.DtResultados.Rows
If dr("CveMetodoPago").ToString.ToEntero = 1 Then
VendidoEfectivo = dr("Importe").ToString.ToDouble
strDetalle.AppendFormat("<tr class='Texto'> <td>{0}</td> <td style='text-align: right'>${1}</td> </tr>",
dr("MetodoPago"), (dr("Importe").ToString.ToDouble - objPV.Propina).FormatoNumero)
Else
strDetalle.AppendFormat("<tr class='Texto'> <td>{0}</td> <td style='text-align: right'>${1}</td> </tr>",
dr("MetodoPago").ToString, dr("Importe").ToString.FormatoNumero)
End If
Next
End If
Dim ObjVentas As New ClsPV()
If ObjVentas.GetRepPVVentas("-1", "-1", "-1", "-1", -1, -1, -1, "-1", -1, -1, "-1", CveEmpresa, 6, CveCorte) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
For Each Col As DataColumn In ObjVentas.DtResultados.Columns
If Col.ColumnName.Split("_"c).Length = 3 AndAlso Col.ColumnName.Split("_"c)(1).ToUpper = "TOTAL" Then
strProductos.AppendFormat("<tr class='Texto'> <td>{0}</td> <td style='text-align: right'>${1}</td> </tr>",
Col.ColumnName.Split("_"c)(2).ToUpper, ObjVentas.DtResultados.Rows(0)(Col.ColumnName).ToString.FormatoNumero)
End If
Next
End If
End If
ObjVentas.Dispose()
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
strBody.Append("<head> ")
strBody.Append(" <style type=""text/css""> ")
strBody.Append(" body ")
strBody.Append(" { ")
strBody.Append(" margin:0px; ")
strBody.Append(" padding:0px 0px 0px 0px; ")
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
strBody.Append(" font-size: 10px; ")
strBody.Append(" background-color:#F0F0F0; ")
strBody.Append(" } ")
strBody.Append(" a.Texto ")
strBody.Append(" { ")
strBody.Append(" font-size:11px; ")
strBody.Append(" background-color:#F7F6F3; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" } ")
strBody.Append(" .Texto ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .TextoG ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color: Black; font-family: Verdana; font-size: 10px; vertical-align: middle;height: 20px;")
strBody.Append(" }")
strBody.Append(" .TextoAlterno ")
strBody.Append(" { ")
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
strBody.Append(" vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .BarraIdentidad ")
strBody.Append(" { ")
strBody.Append(" color:#FFFFFF; ")
strBody.Append(" background:#F0F0F0; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" font-size:19px; ")
strBody.Append(" font-style:oblique; ")
strBody.Append(" } ")
strBody.Append(" .Titulos ")
strBody.Append(" { ")
strBody.Append(" background-color: Gray;")
strBody.Append(" color:White; ")
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" } ")
strBody.Append(" .Verde {color: #00CC00;} ")
strBody.Append(" .Negro {color: #000000;} ")
strBody.Append(" .Rojo {color: #FF0000;} ")
strBody.Append(" </style> ")
strBody.Append("</head> ")
strBody.Append("<body> ")
strBody.AppendFormat("<div id='C_div' style='width: 600px'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend><b>Empresa</b></legend>")
strBody.AppendFormat(" <table class='TextoG' border='0' cellpadding='0' cellspacing='0' width='100%'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td><b>{0}</b></td>", objPV.Sucursal)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>{0}</td>", objPV.Empresa)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>{0}</td>", objPV.Direccion)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>Col. {0}</td>", objPV.Colonia)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>{0}, {1}, C.P.{2}</td>", objPV.Ciudad, objPV.Estado, "83333")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td>RFC {0}</td>", objPV.RFC)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat("</div>")
strBody.AppendFormat("<div style='width: 600px'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend><b>Corte de Turno</b></legend>")
strBody.AppendFormat(" <table class='TextoG' style='width:100%'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td><b>Descripcion:</b></td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objPV.Descripcion)
strBody.AppendFormat(" <td><b>Inicio:</b></td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objPV.FechaInicial.ToString("dd/MM/yyyy HH:mm"))
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td><b>Usuario:</b></td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objPV.UsuarioNombre)
strBody.AppendFormat(" <td><b>Termino:</b></td>")
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", objPV.FechaFinal.ToString("dd/MM/yyyy HH:mm"))
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat("</div>")
strBody.AppendFormat("<div style='width: 600px'>")
strBody.AppendFormat(" <table style='width:100%'>")
strBody.AppendFormat(" <tr>")
strBody.AppendFormat(" <td style='vertical-align: top'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend>Movimiento de Efectivo</legend>")
strBody.AppendFormat(" <table width='100%'>")
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Metodo</th>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Importe</th>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Importe Inicial:</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", objPV.ImporteInicial.FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Ventas Efectivo:</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", VendidoEfectivo.FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Entradas:</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", objPV.Ingresado.FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Salidas:</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", objPV.Retirado.FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>Propinas:</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", objPV.Propina.FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td colspan='2'>")
strBody.AppendFormat(" <hr />")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" <tr class='Texto'>")
strBody.AppendFormat(" <td>NETO DE EFECTIVO</td>")
strBody.AppendFormat(" <td style='text-align: right'>${0}</td>", (objPV.ImporteInicial + VendidoEfectivo + objPV.Ingresado - objPV.Retirado - objPV.Propina).FormatoNumero)
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" <td style='vertical-align: top'>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend>Detalles de Pagos</legend>")
strBody.AppendFormat(" <table width='100%'>")
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Metodo</th>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Importe</th>")
strBody.AppendFormat(" </tr>")
'POngo el detalle
strBody.AppendFormat("{0}", strDetalle.ToString)
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat(" <fieldset>")
strBody.AppendFormat(" <legend>Ventas por Categoria de Producto</legend>")
strBody.AppendFormat(" <table width='100%'>")
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Categoria</th>")
strBody.AppendFormat(" <th scope='col' style='width: 50%'>Importe</th>")
strBody.AppendFormat(" </tr>")
'Pongo el detalle por productos
strBody.AppendFormat("{0}", strProductos.ToString)
strBody.AppendFormat(" </table>")
strBody.AppendFormat(" </fieldset>")
strBody.AppendFormat(" </td>")
strBody.AppendFormat(" </tr>")
strBody.AppendFormat(" </table>")
strBody.AppendFormat("</div>")
strBody.Append("</body></html>")
End If
End If
objPV.Dispose()
Return strBody.ToString
End Function
#End Region
End Class