reportes

Download Reportes

If you can't read please download the document

Upload: dannek-ivan-miranda-lopez

Post on 19-Dec-2015

5 views

Category:

Documents


2 download

DESCRIPTION

Codigo para reportar en C#

TRANSCRIPT

void Reportar() { Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 10); try { PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream); //Open PDF Document to write data pdfDoc.Open(); iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); pdfDoc.Add(new Paragraph("Orden Aprobada")); pdfDoc.Add(Chunk.NEWLINE); string cadenaFinal = ""; PdfPTable tblPrueba = new PdfPTable(2); PdfPCell cl1 = new PdfPCell(new Phrase("", _standardFont)); PdfPCell cl2 = new PdfPCell(new Phrase("", _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("ID_Venta", _standardFont)); cl2 = new PdfPCell(new Phrase( TextBox1.Text , _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Nit del Cliente", _standardFont)); cl2 = new PdfPCell(new Phrase(nitdelcliente(Convert.ToInt32(TextBox1.Text)), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Nombre", _standardFont)); cl2 = new PdfPCell(new Phrase(nombrecliente(nitdelcliente(Convert.ToInt32(TextBox1.Text))), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Domicilio", _standardFont)); cl2 = new PdfPCell(new Phrase(dircliente(nitdelcliente(Convert.ToInt32(TextBox1.Text))), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("nit del Vendedor", _standardFont)); cl2 = new PdfPCell(new Phrase(nitvendedor(), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("nit del Vendedor", _standardFont)); cl2 = new PdfPCell(new Phrase(nitvendedor(), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Le Atendi ", _standardFont)); cl2 = new PdfPCell(new Phrase(nombre, _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Puesto del Vendedor ", _standardFont)); cl2 = new PdfPCell(new Phrase("Administrador", _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Monto a Pagar ", _standardFont)); cl2 = new PdfPCell(new Phrase(monto(Convert.ToInt32(TextBox1.Text)), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Fecha aprobacin : ", _standardFont)); cl2 = new PdfPCell(new Phrase(System.DateTime.Today.ToString() ,_standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Aprobada por : ", _standardFont)); cl2 = new PdfPCell(new Phrase(nombre, _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Cargo ", _standardFont)); cl2 = new PdfPCell(new Phrase("Administrador", _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); cl1 = new PdfPCell(new Phrase("Detalle ", _standardFont)); cl2 = new PdfPCell(new Phrase( detalle(Convert.ToInt32(TextBox1.Text)), _standardFont)); tblPrueba.AddCell(cl1); tblPrueba.AddCell(cl2); pdfDoc.Add(tblPrueba); //Close your PDF pdfDoc.Close(); Response.ContentType = "application/pdf"; //Set default file Name as current datetime Response.AddHeader("content-disposition", "attachment; filename=Recibo.pdf"); System.Web.HttpContext.Current.Response.Write(pdfDoc); Response.Flush(); Response.End(); } catch (Exception ex) { Response.Write(ex.ToString()); } }