Descarga FActuras Rep Productos Servicios

This commit is contained in:
Rakcsle Supertramp
2020-05-02 13:02:20 -07:00
parent 2fdcfc2ff7
commit 2389af5eeb
2 changed files with 119 additions and 33 deletions

View File

@@ -73,6 +73,22 @@
</li>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpDescargaZipPDF" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<li>
<asp:LinkButton ID="BtnDescargarZipPDF" runat="server"> <i class="fa fa-cloud-download"></i> Descargar Facturas</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID= "BtnDescargarZipPDF" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="E" runat="Server">
Reporte de Productos Servicios
@@ -294,7 +310,9 @@
</asp:UpdatePanel>
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GvDatos" runat="server" Width="99%" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados" ToolTip="Listado de Ventas" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" GridLines="None">
<asp:GridView ID="GvDatos" runat="server" Width="99%" AutoGenerateColumns="False" EmptyDataText="No se encontraron Ventas con los filtros especificados" ToolTip="Listado de Ventas"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD" GridLines="None" DataKeyNames="TipoDocumento,SerieFolio" >
<Columns>
<asp:HyperLinkField HeaderText="Serie Folio" DataTextField="SerieFolio" Target="_blank" DataNavigateUrlFields="CveVenta" DataNavigateUrlFormatString="~/Ventas/Ventas.aspx?CveVenta={0}" ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Fecha" DataField="Fecha" DataFormatString="{0:d}" ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center" />
@@ -316,6 +334,7 @@
<RowStyle CssClass="Texto" />
<HeaderStyle CssClass="Titulos" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UPPersonalizar" UpdateMode="Conditional">

View File

@@ -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:<br />")
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}<br />", 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