Exemplo n.º 1
0
        public ActionResult Details(long?id, int page = 1)
        {
            OrdenesPagoCabDetVM opvm = new OrdenesPagoCabDetVM();

            opvm            = _repo.GetOrdenPagoCab(id);
            opvm.pagingInfo = new PagingInfo
            {
                CurrentPage  = page,
                ItemsPerPage = _pageSize,
                TotalItems   = opvm.list.Count()
            };
            return(View(opvm));
        }
Exemplo n.º 2
0
        public void ExportPDF([Bind(Include = "id")] long id)
        {
            OrdenesPagoCabDetVM OP       = _repo.GetOrdenPagoCab(id);
            Document            document = new Document();

            document.Open();
            Font fontTitle   = FontFactory.GetFont(FontFactory.COURIER_BOLD, 25);
            Font font9       = FontFactory.GetFont(FontFactory.TIMES, 9);
            Font tituloTabla = FontFactory.GetFont(FontFactory.TIMES_BOLD, 9);

            //Cabecera
            Paragraph title = new Paragraph(20, "Orden de Pago", fontTitle);

            title.Alignment = Element.ALIGN_CENTER;
            document.Add(title);
            document.Add(new Paragraph(23, "Nro de Orden: " + OP.id, font9));
            document.Add(new Paragraph(24, "Fecha: " + OP.Fecha.ToShortDateString(), font9));
            document.Add(new Paragraph(25, "Profesional: " + OP.Profesional, font9));
            document.Add(new Paragraph(26, "Importe Total: " + OP.Importe, font9));
            document.Add(new Chunk("\n"));

            //Detalle
            DataTable dt = CreateDetalleDataTable();

            foreach (var item in OP.list)
            {
                DataRow row = dt.NewRow();
                row["Factura"]       = item.factura_proveedor_id;
                row["Paga Total"]    = item.PagaTotal;
                row["Forma Pago"]    = item.FormaPago;
                row["Banco"]         = item.Banco;
                row["Nro Cheque"]    = item.NroCheque;
                row["Nro Cta Cte"]   = item.NroCtaCte;
                row["Observaciones"] = item.Observaciones;
                row["Importe"]       = item.Importe;
                dt.Rows.Add(row);
            }
            PdfPTable table = new PdfPTable(dt.Columns.Count);

            float[] widths = new float[dt.Columns.Count];
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                widths[i] = 4f;
            }

            table.SetWidths(widths);
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = Element.ALIGN_CENTER;

            foreach (DataColumn c in dt.Columns)
            {
                PdfPCell  cell = new PdfPCell();
                Paragraph p    = new Paragraph(c.ColumnName, tituloTabla);
                p.Alignment = Element.ALIGN_CENTER;
                cell.AddElement(p);
                table.AddCell(cell);
            }
            foreach (DataRow r in dt.Rows)
            {
                if (dt.Rows.Count > 0)
                {
                    for (int h = 0; h < dt.Columns.Count; h++)
                    {
                        PdfPCell  cell = new PdfPCell();
                        Paragraph p    = new Paragraph(r[h].ToString(), font9);
                        p.Alignment = Element.ALIGN_CENTER;
                        cell.AddElement(p);
                        table.AddCell(cell);
                    }
                }
            }
            document.Add(table);
            document.Close();
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Orden de Pago - Nro " + OP.id + ".pdf");
            HttpContext.Response.Write(document);
            Response.Flush();
            Response.End();
        }