diff --git a/Ventas/RepProductosServiciosDetalle.aspx b/Ventas/RepProductosServiciosDetalle.aspx
index c2ef1feb3..de2f98f82 100644
--- a/Ventas/RepProductosServiciosDetalle.aspx
+++ b/Ventas/RepProductosServiciosDetalle.aspx
@@ -73,6 +73,22 @@
+
+
+
+
+ Descargar Facturas
+
+
+
+
+
+
+
+
+
+
+
Reporte de Productos Servicios
@@ -294,7 +310,9 @@
-
+
+
@@ -316,6 +334,7 @@
+
diff --git a/Ventas/RepProductosServiciosDetalle.aspx.vb b/Ventas/RepProductosServiciosDetalle.aspx.vb
index 5e60d1ee1..52e61382c 100644
--- a/Ventas/RepProductosServiciosDetalle.aspx.vb
+++ b/Ventas/RepProductosServiciosDetalle.aspx.vb
@@ -2,12 +2,14 @@
Option Strict On
Imports System.Data
+Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
+Imports System.IO.Compression
Partial Class Ventas_RepProductosServiciosDetalle
- Inherits ClsPaginas
-
+ Inherits ClsPaginas
+
#Region "PROPIEDADES"
Private Property TmpDT As DataTable
Get
@@ -57,9 +59,9 @@ Partial Class Ventas_RepProductosServiciosDetalle
Set(value As String)
ViewState("Agrupador") = value
End Set
- End Property
+ End Property
#End Region
-
+
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
@@ -68,11 +70,11 @@ Partial Class Ventas_RepProductosServiciosDetalle
CargaParametrosDetalle()
End If
- End Sub
-
-
+ End Sub
+
+
#Region " CARGA DATOS INICIALES "
-
+
Private Sub CargaGrupo()
DdlGrupo.Items.Insert(0, New ListItem("Categoria", "3"))
DdlGrupo.Items.Insert(1, New ListItem("Clasificacion", "4"))
@@ -382,9 +384,9 @@ Partial Class Ventas_RepProductosServiciosDetalle
DdlTipoPSDes.SelectedValueExist(CveClasificacionDetalle)
CargaDatos(CveProyecto, CveSubProyecto, CveCategoria, CveClasificacion, CvePS, Mes, MesEjec, CveCliente, CveSubProyectoEjecucion, CveVendedor, CveUsuario, CveEstatus, GPO.ToEntero, TipoDocto, CveMarca)
CargarMarcas(CveMarca)
- End Sub
+ End Sub
#End Region
-
+
#Region " CARGA DATOS "
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
@@ -465,11 +467,11 @@ Partial Class Ventas_RepProductosServiciosDetalle
End If
DdlMarcaPSDes.Items.Insert(0, New ListItem(" - ", "-1"))
DdlMarcaPSDes.Items.FindByValue(CStr(CveMarca)).Selected = True
- End Sub
+ End Sub
#End Region
-
+
#Region "TIPO CAMBIO"
-
+
Private Sub RblTipoCambio_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoCambio.SelectedIndexChanged
TipoCambio = RblTipoCambio.SelectedValue.ToEntero
If RblTipoCambio.SelectedValue.ToEntero = 3 Then
@@ -481,10 +483,10 @@ Partial Class Ventas_RepProductosServiciosDetalle
LiEspecifico.Visible = False
End If
UpBodyTipoCambio.Update()
- End Sub
-
+ End Sub
+
#End Region
-
+
#Region " GV DATOS - PERSONALIZAR "
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -545,11 +547,11 @@ Partial Class Ventas_RepProductosServiciosDetalle
CargaDatos()
UPDatos.Update()
- End Sub
+ End Sub
#End Region
-
+
#Region " SELECTED INDEX CHANGED"
-
+
Protected Sub DdlClienteClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaClientes()
End Sub
@@ -641,17 +643,17 @@ Partial Class Ventas_RepProductosServiciosDetalle
End If
DdlEstatus.Items.Add(New ListItem("Todos", "-1"))
DdlEstatus.DataBind()
- End Sub
-
-
+ End Sub
+
+
#End Region
-
+
#Region " EXCEL "
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("ReporteProductosServicios" & Now.ToShortDateString)
- End Sub
+ End Sub
#End Region
-
+
#Region " PDF "
Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
ImprimirReporte()
@@ -684,11 +686,11 @@ Partial Class Ventas_RepProductosServiciosDetalle
End If
ObjVentas.Dispose()
- End Sub
+ End Sub
#End Region
-
+
#Region "GRAFICA"
-
+
Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs)
If Not TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then
Alert("No hay datos disponibles", TipoMensaje.MsgAdvertencia)
@@ -818,9 +820,74 @@ Partial Class Ventas_RepProductosServiciosDetalle
Protected Sub DdlVer_SelectedIndexChanged(sender As Object, e As EventArgs)
CambioGrafica()
- End Sub
-
+ End Sub
+
#End Region
-
-
+
+#Region " D E S C A R G A S "
+
+ Private Sub BtnDescargarPDF_Click(sender As Object, e As EventArgs) Handles BtnDescargarZipPDF.Click
+
+
+ 'If Not Directory.Exists(AppDomain.CurrentDomain.BaseDirectory & "Temp\" & UsuarioActual.CveUsuario.ToString & "\") Then
+ ' Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory & "Temp\" & UsuarioActual.CveUsuario.ToString & "\")
+ 'End If
+
+
+ Dim Archivo As String = String.Empty
+ Dim HuboInexistentes As Boolean = False
+ Dim SBInexistentes As New StringBuilder : SBInexistentes.Append("No se pudieron anexar los siguientes archivos:
")
+
+ Dim ArchivoDestino As String = String.Format("{0}Temp\{1}.zip", AppDomain.CurrentDomain.BaseDirectory, Now.ToString("yyyyMMddhhmmss") & UsuarioActual.CveUsuario.ToString)
+
+ Dim archiveZip As ZipArchive = ZipFile.Open(ArchivoDestino, ZipArchiveMode.Create)
+
+ Dim DTVentas As DataTable = TmpDT.FiltraParametros("", "", {"CveVenta", "TipoDocumento", "Folio", "SerieFolio"})
+
+ Try
+
+ For Each Drow As DataRow In DTVentas.Rows
+
+ Dim SerieFolio As String = Drow("SerieFolio").ToString.Replace("-", "_")
+
+ If Drow("TipoDocumento").ToString.Trim <> String.Empty Then
+ Archivo = String.Format("{0}PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta.Replace("\", "/"), Drow("TipoDocumento").ToString, Drow("SerieFolio").ToString)
+ If File.Exists(Archivo) Then
+ archiveZip.CreateEntryFromFile(Archivo, Drow("SerieFolio").ToString & ".pdf")
+ ' Exit For
+ Else
+ HuboInexistentes = True
+ SBInexistentes.AppendFormat("Tipo {0}, Folio {1} - {2}
", Drow("TipoDocumento").ToString, SerieFolio, Archivo)
+ End If
+ End If
+ Next
+
+
+ Catch ex As Exception
+
+ End Try
+
+ archiveZip.Dispose()
+
+
+ Response.Clear()
+ Response.ContentType = "application/zip"
+ Response.AddHeader("content-disposition", $"attachment; filename=facturas{Now.ToString("yyyyMMddhhmmss")}.zip")
+ Response.TransmitFile(ArchivoDestino)
+ Response.Flush()
+
+ Try
+ File.Delete(ArchivoDestino)
+ Catch ex As Exception
+
+ End Try
+
+ Response.End()
+
+ End Sub
+
+#End Region
+
+
+
End Class