Merge branch 'master' of http://oirigoyen@192.168.10.111:8383/SIG.git
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
<%@ WebHandler Language="VB" Class="TareasProgramadas" %>
|
||||
|
||||
<%@ WebHandler Language="VB" Class="TareasProgramadas" %>
|
||||
|
||||
Imports System
|
||||
Imports System.Web
|
||||
Imports System.Data
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports Extensiones
|
||||
Imports System.IO
|
||||
Imports System.IO
|
||||
Imports CrystalDecisions.CrystalReports.Engine
|
||||
Imports CrystalDecisions.Shared
|
||||
|
||||
Public Class TareasProgramadas : Implements IHttpHandler
|
||||
|
||||
@@ -16,14 +19,19 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
currentcontext = context
|
||||
'timbrarNominab()
|
||||
Dim retorno As String = "no se encontro la variable"
|
||||
Try
|
||||
URLParametros = Parametros(context.Request("var"))
|
||||
Try
|
||||
If context.Request("var") IsNot Nothing Then
|
||||
URLParametros = Parametros(context.Request("var"))
|
||||
End If
|
||||
|
||||
Dim metodo As String = URLParametros("metodo")
|
||||
Select Case metodo
|
||||
Case "TimbrarNomina"
|
||||
retorno = "Error Timbrado Nomina"
|
||||
retorno = timbrarNomina()
|
||||
retorno = ""
|
||||
retorno = ""
|
||||
Case "EstadosCuenta"
|
||||
IniciaEnvioEstadoDeCuenta(context, 1, "-1", "-1")
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
ex.GuardaLog(ex.ToString())
|
||||
@@ -127,18 +135,18 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
|
||||
|
||||
Private Function GetUsuario(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional username As String = "", Optional pass As String = "") As Usuario
|
||||
Dim usuario As Usuario = Nothing
|
||||
Dim usuario As Usuario = Nothing
|
||||
#Region "Valido que los campos usuario contraseña no sean nulos"
|
||||
|
||||
|
||||
If IsNothing(username) Then
|
||||
username = ""
|
||||
End If
|
||||
If IsNothing(pass) Then
|
||||
pass = ""
|
||||
End If
|
||||
End If
|
||||
#End Region
|
||||
#Region "Si el CveUsuario es mayor que cero asigno el username y pass la de la CveUsuario"
|
||||
|
||||
|
||||
If CveUsuario > 0 Then
|
||||
Using Dv As New DataView(DirectCast(currentcontext.Application("GlobalDTUsuarios"), DataTable), $"CveUsuario = 100 AND CveEmpresa ={CveEmpresa}", "", DataViewRowState.CurrentRows)
|
||||
Using GlobalDTUsuarios As DataTable = Dv.ToTable()
|
||||
@@ -149,13 +157,13 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
End If
|
||||
End Using
|
||||
End Using
|
||||
End If
|
||||
End If
|
||||
#End Region
|
||||
#Region "obtengo el usuario con el username y la pass"
|
||||
|
||||
|
||||
Using ObjUsuario As New ClsSisUsuarios()
|
||||
usuario = ObjUsuario.ValidaUsuario(username, pass, IMEI, CveEmpresa)
|
||||
End Using
|
||||
End Using
|
||||
#End Region
|
||||
#Region "Asigno la empresa al usuario"
|
||||
If Not IsNothing(usuario) Then
|
||||
@@ -179,7 +187,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
End If
|
||||
End Using
|
||||
|
||||
End If
|
||||
End If
|
||||
#End Region
|
||||
Return usuario
|
||||
End Function
|
||||
@@ -224,8 +232,6 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Function Parametros(Cadena As String) As Hashtable
|
||||
Cadena = Decripta(Cadena)
|
||||
Dim P1() As String = Cadena.Split("&"c)
|
||||
@@ -244,6 +250,426 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
End Property
|
||||
|
||||
|
||||
#Region "E S T A D O S D E C U E N T A"
|
||||
Private Sub CargaEstadosCuenta(ByVal context As HttpContext)
|
||||
Dim DtEmpresas As DataTable = Nothing
|
||||
|
||||
Dim ObjEmpresas As New ClsSisEmpresas()
|
||||
If ObjEmpresas.GetEmpresas(-1, "-1", "-1", "-1", "-1") Then
|
||||
DtEmpresas = ObjEmpresas.DtResultados.FiltraParametros("", "", {"CveEmpresa"})
|
||||
End If
|
||||
ObjEmpresas.Dispose()
|
||||
|
||||
If DtEmpresas IsNot Nothing Then
|
||||
For Each Row As DataRow In DtEmpresas.Rows
|
||||
IniciaEnvioEstadoDeCuenta(context, Row("CveEmpresa").ToString().ToEntero(), "-1", "-1")
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub IniciaEnvioEstadoDeCuenta(ByVal context As HttpContext, CveEmpresa As Integer, pFechaI As String, pFechaF As String)
|
||||
Dim JsonRetorno As New JObject()
|
||||
If CveEmpresa > 0 Then
|
||||
Dim Usuario = ValidaUsuarioSistema(CveEmpresa)
|
||||
Dim FechaI, FechaF As DateTime
|
||||
|
||||
If pFechaI <> "-1" AndAlso pFechaF <> "-1" Then
|
||||
Dim FechaReferencia = DateTime.Now
|
||||
|
||||
Dim DiaAnterior = FechaReferencia.AddDays(-1)
|
||||
Dim DiaAnteriorSemanaPasada = DiaAnterior.AddDays(-7)
|
||||
|
||||
FechaI = New DateTime(DiaAnteriorSemanaPasada.Year, DiaAnteriorSemanaPasada.Month, DiaAnteriorSemanaPasada.Day, 0, 0, 0)
|
||||
FechaF = New DateTime(DiaAnterior.Year, DiaAnterior.Month, DiaAnterior.Day, 23, 59, 59)
|
||||
|
||||
JsonRetorno = EjecutarEnvioEstadoCuenta(Usuario, FechaI, FechaF)
|
||||
Else
|
||||
FechaI = pFechaI.ToDateTime()
|
||||
FechaF = pFechaF.ToDateTime()
|
||||
|
||||
JsonRetorno = EjecutarEnvioEstadoCuenta(Usuario, FechaI, FechaF)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function ValidaUsuarioSistema(CveEmpresa As Integer) As Usuario
|
||||
Dim UsuarioActual As Usuario = Nothing
|
||||
Dim ObjUsuarios As New ClsSisUsuarios
|
||||
If ObjUsuarios.GetUsuarios(100) Then
|
||||
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
||||
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
||||
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
||||
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
||||
UsuarioActual.CveEmpresa = CveEmpresa
|
||||
CreaObjetoEmpresa(UsuarioActual)
|
||||
End If
|
||||
End If
|
||||
ObjUsuarios.Dispose()
|
||||
Return UsuarioActual
|
||||
End Function
|
||||
|
||||
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||
|
||||
Dim ObjEmpresa As New ClsSisEmpresas()
|
||||
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||
|
||||
Dim EmpresasFuncionalidades As New HybridDictionary
|
||||
For Each Row As Data.DataRow In dttmp.Rows
|
||||
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||
Next
|
||||
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||
End If
|
||||
|
||||
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||
End If
|
||||
ObjEmpresa.Dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function EjecutarEnvioEstadoCuenta(UsuarioActual As Usuario, FechaI As DateTime, FechaF As DateTime) As JObject
|
||||
Dim Facturas As New JArray()
|
||||
Dim DebeTimbrar As Boolean = True
|
||||
|
||||
Dim Json As New JObject(
|
||||
New JProperty("Empresa", UsuarioActual.Empresa.Empresa),
|
||||
New JProperty("Usuario", UsuarioActual.Usuario),
|
||||
New JProperty("FechaI", FechaI.ToString("dd/MM/yyy HH:mm:ss")),
|
||||
New JProperty("FechaF", FechaF.ToString("dd/MM/yyy HH:mm:ss"))
|
||||
)
|
||||
Dim DTClientes As DataTable = Nothing
|
||||
|
||||
Dim ObjCliente As New ClsClientes
|
||||
If ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, TipoCliente:=-1) Then
|
||||
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
DTClientes = ObjCliente.DtResultados.Copy()
|
||||
End If
|
||||
End If
|
||||
ObjCliente.Dispose()
|
||||
|
||||
If DTClientes IsNot Nothing Then
|
||||
For Each RowCliente As DataRow In DTClientes.Rows
|
||||
Dim CveCliente As Integer = RowCliente("CveCliente").ToString().ToEntero()
|
||||
Dim Correo As String = "jonathan.perez@adssistemas.mx" 'RowCliente("Correo").ToString()
|
||||
|
||||
Dim Cliente As New Modelos.ClienteModel(CveCliente, UsuarioActual.CveEmpresa)
|
||||
|
||||
GenerarPDFCrystal(UsuarioActual, Correo, "-1", "-1", Cliente)
|
||||
Next
|
||||
DTClientes.Dispose()
|
||||
End If
|
||||
Json.Add(New JProperty("Facturas", Facturas))
|
||||
|
||||
Return Json
|
||||
End Function
|
||||
|
||||
Private Sub GenerarPDFCrystal(UsuarioActual As Usuario, Correo As String, FI As String, FF As String, Cliente As Modelos.ClienteModel)
|
||||
Dim ArchivoPDF As Byte() = Nothing
|
||||
|
||||
Dim Formato As String = "PDF"
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.rpt", UsuarioActual.Empresa.Ruta))
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
'OBTENEMOS LOS DATOS
|
||||
Dim DtCxCFact As DataTable = Nothing
|
||||
|
||||
Dim SaldoIngDolares As Double = 0
|
||||
Dim SaldoIngPesos As Double = 0
|
||||
Dim SaldoIngDolaresPesos As Double = 0
|
||||
Dim TotalIng As Double = 0
|
||||
Dim SaldoAntDolares As Double = 0
|
||||
Dim SaldoAntPesos As Double = 0
|
||||
Dim SaldoAntDolaresPesos As Double = 0
|
||||
Dim TotalAnt As Double = 0
|
||||
Dim ContaIng As Integer = 0
|
||||
Dim ContaAnt As Integer = 0
|
||||
Dim FechaCorte As Date = ("9999/01/01").ToDate
|
||||
Dim TipoDocto As String = "-1"
|
||||
Dim TipoDocto2 As String = "-1"
|
||||
Dim FechaVencimientoI As String = "-1"
|
||||
Dim FechaVencimientoF As String = "-1"
|
||||
Dim dtt As DataTable = Nothing
|
||||
|
||||
Dim ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetCxCClienteDetalle(Cliente.CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, CveClienteSucursal:=-1) Then
|
||||
DtCxCFact = ObjMovtos.DtResultados.FiltraParametros("", "TipoDocto").Copy
|
||||
'cargo los anticipos NC
|
||||
DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal))
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(Cliente.CveCliente, -1, -1) Then
|
||||
dtt = ObjMovtos.DtResultados.FiltraParametros("SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")
|
||||
End If
|
||||
End If
|
||||
ObjMovtos.Dispose()
|
||||
|
||||
Try
|
||||
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
|
||||
For Each drt As DataRow In dtt.Rows
|
||||
Dim drr As DataRow = DtCxCFact.NewRow
|
||||
drr("TipoDocto") = drt("Tipo")
|
||||
drr("SerieFolio") = drt("Folio")
|
||||
drr("Original") = drt("Original")
|
||||
drr("TipoCambio") = drt("TipoCambio")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = drt("Saldo")
|
||||
drr("Fecha") = drt("Fecha")
|
||||
drr("Moneda") = drt("Moneda")
|
||||
drr("CveMoneda") = drt("CveMoneda")
|
||||
DtCxCFact.Rows.Add(drr)
|
||||
Next
|
||||
End If
|
||||
|
||||
If DtCxCFact IsNot Nothing Then
|
||||
For Each Row As DataRow In DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})").Rows
|
||||
If Row("TipoDocto").ToString = "Ing" Or Row("TipoDocto").ToString = "Rem" Or (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble > 0) Then 'Ingresos
|
||||
ContaIng = ContaIng + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
SaldoIngPesos = SaldoIngPesos + Row("Saldo").ToString.ToDouble
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoIngDolares = SaldoIngDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
End If
|
||||
|
||||
ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC
|
||||
ContaAnt = ContaAnt + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
If Row("TipoDocto").ToString = "Dev" Then
|
||||
SaldoAntPesos = SaldoAntPesos + Row("Saldo").ToString.ToDouble
|
||||
Else
|
||||
SaldoAntPesos = SaldoAntPesos + Row("SaldoAnticipo").ToString.ToDouble
|
||||
End If
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoAntDolares = SaldoAntDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoAntDolaresPesos = SaldoAntDolaresPesos + (Row("SaldoAnticipo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
TotalIng = SaldoIngPesos + SaldoIngDolaresPesos
|
||||
TotalAnt = SaldoAntPesos + SaldoAntDolaresPesos
|
||||
|
||||
Dim DtCxCFact2 As DataTable = DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})")
|
||||
|
||||
'INGRESOS
|
||||
If SaldoIngPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoIngDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Dólares"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
'ANTICIPOS
|
||||
If SaldoAntPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Pesos"
|
||||
drr("SaldoAnticipo") = SaldoAntPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoAntDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Dólares"
|
||||
drr("SaldoAnticipo") = SaldoAntDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
If DtCxCFact2 IsNot Nothing AndAlso DtCxCFact2.Rows.Count > 0 Then
|
||||
Dim dr As DataRow = DtCxCFact2.Rows(0)
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", ""))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito - DtCxCFact2(0)("Saldo").ToString.ToDouble).FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim File As Byte()
|
||||
If Archivo.Exists Then
|
||||
File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
Else
|
||||
File = ImprimirPDFCrystal(HttpContext.Current.Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar MAIL de Orden de Compra", ex)
|
||||
End Try
|
||||
Else
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", "Todas"))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito).FormatoNumero))
|
||||
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
End If
|
||||
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = 0
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
|
||||
If Archivo.Exists Then
|
||||
ArchivoPDF = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
Else
|
||||
ArchivoPDF = ImprimirPDFCrystal(HttpContext.Current.Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
End If
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ArchivoPDF = Nothing
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim Cuerpo As String = String.Format("Estimado cliente {0}, al presente se correo se anexa su estado actual de cartera en {1}.<br />
|
||||
<br />
|
||||
Quedamos a sus ordenes para cualquier duda o aclaración con su agente de Ventas.<br />
|
||||
<br />
|
||||
<br />
|
||||
Gracias por la atención brindada al presente.<br /> Reciba un cordial saludo.<br />
|
||||
<br />
|
||||
<b>ESTE CORREO SE GENERO EN FORMA AUTOMATICA.</b>", Cliente.NombreComercial, UsuarioActual.Empresa.Empresa)
|
||||
|
||||
MandaCorreo(ArchivoPDF, Correo, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo)
|
||||
Catch ex As Exception
|
||||
Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgAdvertencia)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Function ImprimirPDFCrystal(RutaReporte As String, DataSource As DataTable, Parametros As List(Of CrystalParametro), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportDocument = Nothing) As Byte()
|
||||
'limpio ReportViwer
|
||||
Dim sw As New System.Diagnostics.Stopwatch()
|
||||
sw.Start()
|
||||
If IsNothing(MR) Then MR = New ReportDocument()
|
||||
Dim Bytes As Byte() = Nothing
|
||||
Dim formatType As ExportFormatType = ExportFormatType.NoFormat
|
||||
Try
|
||||
MR.Load(RutaReporte)
|
||||
MR.SetDataSource(DataSource)
|
||||
|
||||
For Each item As CrystalParametro In Parametros
|
||||
MR.SetParameterValue(item.Nombre, item.Valor)
|
||||
Next
|
||||
|
||||
Select Case Formato
|
||||
Case "PDF"
|
||||
formatType = ExportFormatType.PortableDocFormat
|
||||
'Format = "Application/pdf"
|
||||
Case "EXCEL"
|
||||
formatType = ExportFormatType.Excel
|
||||
'Format = "application/ms-excel"
|
||||
End Select
|
||||
Dim Stream As IO.Stream = MR.ExportToStream(formatType)
|
||||
Dim BD As New BinaryReader(MR.ExportToStream(formatType))
|
||||
Bytes = BD.ReadBytes(CInt(MR.ExportToStream(formatType).Length))
|
||||
BD.Dispose()
|
||||
Stream.Dispose()
|
||||
'Dim Buffer(CInt(Stream.Length)) As Byte
|
||||
'Bytes = Buffer
|
||||
'MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo)
|
||||
Catch ex As CrystalReportsException
|
||||
GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing,
|
||||
$"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing,
|
||||
ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}"))
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
Catch ex As Exception
|
||||
GuardaLog(If(ex.InnerException IsNot Nothing AndAlso ex.Message IsNot Nothing,
|
||||
$"Error: {If(ex.InnerException.Message, ex.Message)} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing,
|
||||
ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} Ruta {RutaReporte}", $"Sin descripción - Ruta {RutaReporte}"))
|
||||
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
End Try
|
||||
sw.Stop()
|
||||
If sw.Elapsed.TotalSeconds > 10 Then
|
||||
GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ")
|
||||
End If
|
||||
If MR IsNot Nothing Then MR.Dispose()
|
||||
Return Bytes
|
||||
End Function
|
||||
|
||||
Private Sub MandaCorreo(File As Byte(), Para As String, Asunto As String, Body As String)
|
||||
|
||||
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
||||
'a.GuardaLog()
|
||||
Dim Mail As New ClsSisMail()
|
||||
|
||||
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = File, .NombreArchivo = "EstadoDeCuenta.pdf"})
|
||||
|
||||
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=LSRutasMail)
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
@@ -151,6 +151,7 @@
|
||||
<td width="60px" align="center">Número</td>
|
||||
<td width="300px" align="left">Concepto</td>
|
||||
<td width="100px" align="center">Referencia</td>
|
||||
<td width="100px" align="center">SubProyecto</td>
|
||||
<td width="100px" align="center">Cargos</td>
|
||||
<td width="100px" align="center">Abonos</td>
|
||||
<td width="100px" align="center">Saldo</td>
|
||||
@@ -194,6 +195,9 @@
|
||||
<td width="100px">
|
||||
<asp:Label ID="LbReferencia" runat="server" Text='<%# Eval("Referencia")%>'></asp:Label>
|
||||
</td>
|
||||
<td width="100px">
|
||||
<asp:Label ID="LblSubProyecto" runat="server" Text='<%# Eval("SubProyecto")%>'></asp:Label>
|
||||
</td>
|
||||
<td width="100px" align="right">
|
||||
<asp:Label ID="LbCargos" runat="server"></asp:Label>
|
||||
</td>
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
<Width>1.49458cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>7.13431cm</Width>
|
||||
<Width>4.81952cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>1.99729cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>2.3148cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>2.10313cm</Width>
|
||||
</TablixColumn>
|
||||
@@ -149,11 +152,12 @@
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<ColSpan>3</ColSpan>
|
||||
<ColSpan>4</ColSpan>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell />
|
||||
<TablixCell />
|
||||
<TablixCell />
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox22">
|
||||
@@ -387,6 +391,44 @@
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox2">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Subproyecto</Value>
|
||||
<Style>
|
||||
<FontFamily>Verdana</FontFamily>
|
||||
<FontSize>8pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox2</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<BottomBorder>
|
||||
<Color>Black</Color>
|
||||
<Style>Solid</Style>
|
||||
<Width>1pt</Width>
|
||||
</BottomBorder>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox17">
|
||||
@@ -605,10 +647,11 @@
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<ColSpan>2</ColSpan>
|
||||
<ColSpan>3</ColSpan>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell />
|
||||
<TablixCell />
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox21">
|
||||
@@ -844,6 +887,38 @@
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="SubProyecto">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!SubProyecto.Value</Value>
|
||||
<Style>
|
||||
<FontFamily>Verdana</FontFamily>
|
||||
<FontSize>7pt</FontSize>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>SubProyecto</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="CargosMovto">
|
||||
@@ -1053,6 +1128,40 @@
|
||||
</TablixCell>
|
||||
<TablixCell />
|
||||
<TablixCell />
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox12">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value />
|
||||
<Style>
|
||||
<FontFamily>Verdana</FontFamily>
|
||||
<FontSize>7pt</FontSize>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox12</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Cargos">
|
||||
@@ -1172,6 +1281,7 @@
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
</TablixMembers>
|
||||
</TablixColumnHierarchy>
|
||||
<TablixRowHierarchy>
|
||||
@@ -1208,9 +1318,9 @@
|
||||
</TablixRowHierarchy>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<DataSetName>DataSet1</DataSetName>
|
||||
<Top>0.06348cm</Top>
|
||||
<Top>0.06346cm</Top>
|
||||
<Height>3cm</Height>
|
||||
<Width>20.37043cm</Width>
|
||||
<Width>20.37044cm</Width>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
@@ -1221,7 +1331,7 @@
|
||||
<Height>1.2061in</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>8.04763in</Width>
|
||||
<Width>8.01986in</Width>
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<Height>0.81597in</Height>
|
||||
@@ -1360,7 +1470,7 @@
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox3</rd:DefaultName>
|
||||
<Top>0.07025cm</Top>
|
||||
<Top>0.07023cm</Top>
|
||||
<Left>15.87314cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>4.4973cm</Width>
|
||||
@@ -1463,6 +1573,10 @@
|
||||
<DataField>Saldo</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="SubProyecto">
|
||||
<DataField>SubProyecto</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>DataSet</rd:DataSetName>
|
||||
|
||||
@@ -31,6 +31,16 @@
|
||||
Reporte Indice Rotación de Personal
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="HB" Runat="Server">
|
||||
<asp:UpdatePanel ID="UpAcciones" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<li>
|
||||
<asp:LinkButton runat="server" ID="BtnImprimir" OnClick="BtnImprimir_Click" data-toggle="tooltip" data-placement="left" title="Agregar un Defecto" Text="<i class='fa fa-file-pdf-o'></i>Imprimir"></asp:LinkButton>
|
||||
</li>
|
||||
</ContentTemplate>
|
||||
<Triggers>
|
||||
<asp:PostBackTrigger ControlID="BtnImprimir" />
|
||||
</Triggers>
|
||||
</asp:UpdatePanel>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="H" Runat="Server">
|
||||
</asp:Content>
|
||||
|
||||
@@ -3,10 +3,24 @@ Option Explicit On
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Ventas_RepIndiceRotacionPersonal
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property DTGvDatos As DataTable
|
||||
Get
|
||||
If ViewState("DTGvDatos") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTGvDatos"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTGvDatos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Sub Ventas_RepIndiceRotacionPersonal_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
txtInicio.Text = Date.Now.AddDays(-30).ToString("dd/MM/yyyy")
|
||||
@@ -84,7 +98,7 @@ Partial Class Ventas_RepIndiceRotacionPersonal
|
||||
If rh.GetReporteRotacionPersonal(FechaInicio, FechaFin, CveTurno, CveProyecto, CveSubproyecto, UsuarioActual.Empresa.CveEmpresa) Then
|
||||
dTable = rh.DtResultados
|
||||
End If
|
||||
|
||||
DTGvDatos = dTable
|
||||
GVRegDatos.DataSource = dTable
|
||||
GVRegDatos.DataBind()
|
||||
|
||||
@@ -138,4 +152,29 @@ Partial Class Ventas_RepIndiceRotacionPersonal
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs)
|
||||
'"Empresas/Grales/Formatos/ClienteHistorial.rdlc"
|
||||
If GVRegDatos.Rows.Count > 0 Then
|
||||
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
|
||||
Dim params As New List(Of ReportParameter)
|
||||
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("FechaInicial", txtInicio.Text))
|
||||
params.Add(New ReportParameter("FechaFinal", txtFin.Text))
|
||||
params.Add(New ReportParameter("FechaRealizado", Date.Now().ToString()))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
|
||||
If Imagen.Exists Then
|
||||
params.Add(New ReportParameter("LogoPath", logouri))
|
||||
Else
|
||||
params.Add(New ReportParameter("LogoPath", ""))
|
||||
End If
|
||||
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepIndiceRotacionPersonal.rdlc", DTGvDatos, params, "Reporte de Historial", "PDF")
|
||||
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -9,6 +9,7 @@ Imports Microsoft.Reporting.WebForms
|
||||
Imports System.Security.Cryptography.X509Certificates
|
||||
Imports System.Globalization
|
||||
Imports System.Net.Http
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Partial Class Ventas
|
||||
Inherits ClsPaginas
|
||||
@@ -6733,13 +6734,11 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
'ENVIAR POLIZA VIRTUAL
|
||||
If ErrorList.Count = 0 Then
|
||||
If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then
|
||||
If Not GeneraPolizaVentaWS(ObjVentas, ObjFactura) Then
|
||||
ErrorList.Add("Ocurrió un error al registrar los movimientos de almacén del contrato de consignación")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
'If ErrorList.Count = 0 Then
|
||||
' If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then
|
||||
' GeneraPolizaVentaWS(ObjFactura)
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 Then
|
||||
|
||||
@@ -15309,7 +15308,6 @@ Partial Class Ventas
|
||||
If UsuarioActual.Empresa.Funcionalidad(575) = "1" Then
|
||||
'Le damos salida normal
|
||||
If ConSalida Then
|
||||
|
||||
GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 40, CveMoneda, CveRemision, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0
|
||||
|
||||
If Not GeneroMovimientoAlmacen Then
|
||||
@@ -15319,14 +15317,9 @@ Partial Class Ventas
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
||||
If Not GeneroMovimientoAlmacen Then
|
||||
GeneroMovimientoAlmacen = GenerarMovimientoAlmacenVirtual(ObjInventario, ObjFactura) > 0
|
||||
|
||||
If Not GeneroMovimientoAlmacen Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura)
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
'Le damos salida de apartado por traspaso
|
||||
@@ -15351,12 +15344,7 @@ Partial Class Ventas
|
||||
If ConSalida AndAlso Not OcurrioError Then
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
||||
|
||||
GeneroMovimientoAlmacen = GenerarMovimientoAlmacenVirtual(ObjInventario, ObjFactura) > 0
|
||||
|
||||
If Not GeneroMovimientoAlmacen Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura)
|
||||
End If
|
||||
|
||||
If Not OcurrioError Then
|
||||
@@ -15612,119 +15600,61 @@ Partial Class Ventas
|
||||
'Return Not OcurrioError
|
||||
|
||||
End Function
|
||||
Private Function GenerarMovimientoAlmacenVirtual(ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura) As Integer
|
||||
Private Function GenerarMovimientoAlmacenVirtual(CveRemision As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura) As Boolean
|
||||
Dim OcurrioError As Boolean = False
|
||||
Dim CveMovimientoVirtual As Integer = -1
|
||||
|
||||
Dim DtPSVirtual As New DataTable("DtTamanios")
|
||||
DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer)))
|
||||
DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
|
||||
DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal)))
|
||||
DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer)))
|
||||
Try
|
||||
Dim CveMovimientoVirtual As Integer = -1
|
||||
Dim CveAlmacenVirtual As Integer = -1
|
||||
Dim CveConceptoMovimientoVirtual As Integer = 3
|
||||
Dim DtPSVirtual As DataTable = Nothing
|
||||
Dim DtTamanios As DataTable = Nothing
|
||||
Dim CveMovimientoEntradaDev As Integer = -1
|
||||
|
||||
Dim DtTamanios As DataTable = Nothing
|
||||
Dim ObjAcumuladores As New ClsAcumuladores
|
||||
If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
|
||||
DtTamanios = ObjAcumuladores.DtResultados.Copy()
|
||||
End If
|
||||
ObjAcumuladores.Dispose()
|
||||
If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then
|
||||
Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND CveTipoAlmacen = 24 AND CveConcepto = 2 AND CveVenta > 0")
|
||||
|
||||
Dim CveConceptoMovimientoVirtual As Integer = 3
|
||||
Dim CveAlmacenVirtual As Integer = -1
|
||||
|
||||
For Each GvRow As DataRow In ObjFactura.DtDetalle.Rows
|
||||
For Each Tam As DataRow In DtTamanios.Rows
|
||||
If Tam("CveTamaño").ToString() = GvRow("CveTamaño").ToString() Then
|
||||
Dim CvePSCargo = Tam("CvePSCargo").ToString().ToEntero()
|
||||
Dim Row As DataRow = DtPSVirtual.NewRow()
|
||||
|
||||
Row("CvePS") = CvePSCargo
|
||||
Row("Cantidad") = GvRow("Cantidad").ToString().ToDecimal()
|
||||
Row("PU") = 0
|
||||
Row("CveUM") = GvRow("CveUM").ToString().ToEntero()
|
||||
|
||||
DtPSVirtual.Rows.Add(Row)
|
||||
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={ObjFactura.CveSubProyecto}").ToEntero()
|
||||
|
||||
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 Then
|
||||
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/E")
|
||||
|
||||
If CveMovimientoVirtual > 0 Then
|
||||
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
||||
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
||||
Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
|
||||
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
||||
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
||||
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
CveMovimientoEntradaDev = RowMovimiento("CveMovimiento").ToString().ToEntero()
|
||||
CveAlmacenVirtual = RowMovimiento("CveAlmacen").ToString().ToEntero()
|
||||
Else
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
Else
|
||||
'CARGA CONCEPTOS DEVUELTOS EN LA VENTA
|
||||
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntradaDev, UsuarioActual.CveEmpresa) Then
|
||||
DtPSVirtual = ObjInventario.DtResultados.Copy()
|
||||
Else
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
If Not OcurrioError AndAlso DtPSVirtual.Rows.Count > 0 Then
|
||||
|
||||
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, ObjFactura.CveVenta, -1, -1, Modulo:="Vta/V")
|
||||
|
||||
If CveMovimientoVirtual > 0 Then
|
||||
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
||||
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
||||
Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
|
||||
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
||||
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
||||
|
||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al generar el almacen virtual.", ex)
|
||||
OcurrioError = True
|
||||
End If
|
||||
End Try
|
||||
|
||||
If DtPSVirtual.Rows.Count = 0 Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'Dim ContadorMovtosDetalles = 0
|
||||
|
||||
'Dim DtMovDetalle As DataTable = Nothing
|
||||
'If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
||||
' DtMovDetalle = ObjInventario.DtResultados.Copy()
|
||||
'End If
|
||||
|
||||
''Creamos el movimiento
|
||||
'Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, 2, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoSalida)
|
||||
|
||||
'If CveMovimientoInventario > 0 Then
|
||||
|
||||
' 'Agregamos los detalles
|
||||
' For Each MovDet As DataRow In DtMovDetalle.Rows
|
||||
' Dim Cantidad = MovDet("Cantidad").ToString.ToDecimal
|
||||
' Dim CveUnidad As Integer = MovDet("CveUM").ToString.ToEntero
|
||||
' Dim PU As Decimal = MovDet("PU").ToString.ToDecimal
|
||||
' Dim CveProducto As Integer = MovDet("CvePS").ToString.ToEntero
|
||||
' Dim SerieLote As String = MovDet("SerieLote").ToString
|
||||
|
||||
' If Cantidad < 0 Then
|
||||
' Alert("Ocurrió un Error al generar los movimientos de almacén. Por favor comuniquese con atención SIG.", TipoMensaje.MsgError)
|
||||
' OcurrioError = True
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
' If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, SerieLote:=SerieLote) Then
|
||||
' ContadorMovtosDetalles += 1
|
||||
' Else
|
||||
' OcurrioError = True
|
||||
' Exit For
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' 'VALIDA QUE SE HALLAN AGREGADO DETALLES AL MOVIMIENTO
|
||||
' If ContadorMovtosDetalles = 0 Then
|
||||
' OcurrioError = True
|
||||
' End If
|
||||
|
||||
'Else
|
||||
' OcurrioError = True
|
||||
'End If
|
||||
|
||||
If OcurrioError Then
|
||||
Return -1
|
||||
Else
|
||||
Return CveMovimientoVirtual
|
||||
End If
|
||||
Return Not OcurrioError
|
||||
|
||||
End Function
|
||||
Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
|
||||
@@ -23810,12 +23740,13 @@ Partial Class Ventas
|
||||
CargaRNC()
|
||||
RegistraScript("$('#ModalAplicarRemisionesNC').modal({backdrop: 'static', keyboard: false });")
|
||||
End Sub
|
||||
Protected Function GeneraPolizaVentaWS(ByRef ObjVentas As ClsVentas, ObjFactura As Modelos.Factura) As Boolean
|
||||
Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura)
|
||||
Dim DtUsados As DataTable = Nothing
|
||||
|
||||
If ObjVentas.GetVentasUsadosDetalle(ObjFactura.CveVenta) Then
|
||||
DtUsados = ObjVentas.DtResultados.Copy()
|
||||
Dim ObjAcum As New ClsAcumuladores
|
||||
If ObjAcum.GetGarantiasDetalle(ObjFactura.CveVenta) Then
|
||||
DtUsados = ObjAcum.DtResultados.Copy()
|
||||
End If
|
||||
ObjAcum.Dispose()
|
||||
|
||||
For Each Row As DataRow In DtUsados.Rows
|
||||
Dim obj As New Modelos.MPolizaVentaWS
|
||||
@@ -23842,7 +23773,7 @@ Partial Class Ventas
|
||||
obj.sale_id = String.Format("{0}{1}{2}", ObjFactura.Serie, ObjFactura.Folio, ObjFactura.CveVenta)
|
||||
|
||||
'DATOS DEL PRODUCTO
|
||||
obj.product_code = Row("Codigo").ToString()
|
||||
obj.product_code = Row("Code17").ToString()
|
||||
obj.product_unique_code = "" 'se indique el código único de la batería.
|
||||
obj.product_sale_type = "01 " 'VENTA
|
||||
|
||||
@@ -23859,11 +23790,10 @@ Partial Class Ventas
|
||||
EnviarPolizaVentaWS(obj)
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Protected Sub EnviarPolizaVentaWS(obj As Modelos.MPolizaVentaWS)
|
||||
End Sub
|
||||
|
||||
Protected Function EnviarPolizaVentaWS(obj As Modelos.MPolizaVentaWS) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
Dim Respuesta As String = "[]"
|
||||
|
||||
Dim User As String = "cslth.2809@jcilink.com"
|
||||
@@ -23909,11 +23839,29 @@ Partial Class Ventas
|
||||
Dim response = wc.PostAsync(Url, content).Result
|
||||
|
||||
Respuesta = response.Content.ReadAsStringAsync().Result
|
||||
|
||||
Dim resp = JArray.Parse(Respuesta)
|
||||
|
||||
If resp.Count > 0 Then
|
||||
Dim Msg = resp(0)("Descripcion").ToString()
|
||||
|
||||
If resp(0)("Codigo").ToString().Contiene("500", "501", "502", "503", "504", "505", "506", "507", "508") Then
|
||||
Alert(Msg, TipoMensaje.MsgInformacion)
|
||||
Retorno = True
|
||||
Else
|
||||
Alert(Msg, TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
Else
|
||||
Alert("No se envió la poliza virtual", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
End Using
|
||||
|
||||
Catch ex As Exception
|
||||
ex.GuardaLog(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user