impresión masica
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkExcel" OnClick="LnkExcel_Click" runat="server"><i class="fa fa-file-excel-o" style="font-weight:bold;"></i> Exporta Excel</asp:LinkButton>
|
||||
</li>
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkImpresionMasiva" OnClick="LnkImpresionMasiva_Click" runat="server"> <i class="fa fa-download" style="font-weight:bold;"></i> Descargar PDFs</asp:LinkButton>
|
||||
</li>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content6" ContentPlaceHolderID="HA" Runat="Server">
|
||||
</asp:Content>
|
||||
@@ -92,7 +95,7 @@
|
||||
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvSolicitudes.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<asp:GridView ID="GvSolicitudes" runat="server" GridLines="None" DataKeyNames="Folio, RazonSocial, ImporteSol, FolioMov, Importe, Nombre"
|
||||
<asp:GridView ID="GvSolicitudes" runat="server" GridLines="None" DataKeyNames="CveOrdenCompra,Folio, RazonSocial, ImporteSol, FolioMov, Importe, Nombre"
|
||||
CssClass="table table-striped table-advance table-hover Widthall mysmallbtn ScrollAD" data-sort="true" data-footer="0" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False"
|
||||
EmptyDataText="No se encontraron registros">
|
||||
<Columns>
|
||||
|
||||
@@ -9,7 +9,11 @@ using System.Web.UI.WebControls;
|
||||
using Extensiones;
|
||||
using Microsoft.Reporting.WebForms;
|
||||
using static Extensiones.ModExtensiones;
|
||||
|
||||
using iTextSharp;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using System.IO;
|
||||
using Ionic.Zip;
|
||||
public partial class OC_RepSolicitudesAnticipo : ClsPaginas
|
||||
{
|
||||
#region "Propiedades"
|
||||
@@ -75,7 +79,7 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas
|
||||
{
|
||||
DdlProveedor.DataSource = get_GlobalDTCompProveedores(UsuarioActual.CveEmpresa);
|
||||
DdlProveedor.DataBind();
|
||||
DdlProveedor.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
DdlProveedor.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Todos", "-1"));
|
||||
DdlProveedor.SelectedValue = "-1";
|
||||
}
|
||||
|
||||
@@ -124,6 +128,10 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas
|
||||
{
|
||||
GenerarPDF("PDF");
|
||||
}
|
||||
protected void LnkImpresionMasiva_Click(object sender,EventArgs e)
|
||||
{
|
||||
GenerarImpresionMasiva();
|
||||
}
|
||||
|
||||
protected void GenerarPDF(String Opcion)
|
||||
{
|
||||
@@ -161,4 +169,44 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas
|
||||
Alert("No hay datos consultados", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerarImpresionMasiva()
|
||||
{
|
||||
|
||||
byte[] all;
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (Document d = new Document())
|
||||
{
|
||||
using (PdfCopy copy = new PdfCopy(d,ms))
|
||||
{
|
||||
d.Open();
|
||||
foreach (GridViewRow Gvr in GvSolicitudes.Rows)
|
||||
{
|
||||
int CveOC = Gvr.DataKey("CveOrdenCompra").ToEntero();
|
||||
byte[] reporteByte = NewGeneraBytesOC(CveOC);
|
||||
PdfReader reader = new PdfReader(reporteByte);
|
||||
int n = reader.NumberOfPages;
|
||||
int page = 0;
|
||||
while (page < n)
|
||||
{
|
||||
page++;
|
||||
copy.AddPage(copy.GetImportedPage(reader, page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
all = ms.ToArray();
|
||||
}
|
||||
//ImprimirbytesPDF(all, "RepSolicitudesAnticipo");
|
||||
|
||||
ZipFile zip = new ZipFile();
|
||||
zip.AddEntry("RepSolicitudesAnticipo", all);
|
||||
zip.Save(Response.OutputStream);
|
||||
Response.AddHeader("content-Disposition", "attachment; filename=RepSolicitudesAnticipo.zip");
|
||||
Response.ContentType = "application/zip";
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user