private void GenerarPDF(string dir) { try { IBuenasPracticasDominio dominio = IoC.GetObjectDominio <Dominio.Interfaces.Dominio.IBuenasPracticasDominio>(); //IoC.GetObjectDominio<Dominio.Interfaces.Dominio.Guia.IDestinoGuiaDominio>().GetAgenciasDestino(); IList <BuenasPracticasCompleto> lista = new List <BuenasPracticasCompleto>(); lista = dominio.GetBuenasPracticasCompletoSEL(DateTime.Now.AddDays(-360), DateTime.Now, int.Parse(lblParteNro.Text)); Document document = new Document(); PdfWriter.GetInstance(document, new FileStream(dir + ".pdf", FileMode.OpenOrCreate)); document.Open(); document.Add(new Paragraph("BUENA PRACTICA EMITIDA")); document.Add(Chunk.NEWLINE); PdfPTable tblBuenaPractica = new PdfPTable(2); tblBuenaPractica.WidthPercentage = 100; iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); PdfPCell clCarac = new PdfPCell(new Phrase("Caracteristica", _standardFont)); clCarac.BorderWidth = 0; clCarac.BorderWidthBottom = 0.75f; PdfPCell clDescrip = new PdfPCell(new Phrase("Descripcion", _standardFont)); clDescrip.BorderWidth = 0; clDescrip.BorderWidthBottom = 0.75f; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); string desc = ""; // if (this.chDescontar.Checked) if (lista[0].Descontar) { desc = "Si"; } else { desc = "No"; } clCarac = new PdfPCell(new Phrase("Parte Nro.: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblParteNro.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].BuenasPracticasEmisionID.ToString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Movil: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblBuenaPracticaMovilSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Numero, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Dominio: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblDominioBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Dominio, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Responsable: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblResponsableBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Chofer, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Buena Practica: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblBuenaPracticaDescripcion.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Descrip, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Emitida Por: ", _standardFont)); clCarac.BorderWidth = 0; // clDescrip = new PdfPCell(new Phrase(this.lblUsuarioBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Usuario, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Fecha Emision: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblFechaBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].FechaEmision.Value.ToShortDateString() + " " + lista[0].FechaEmision.Value.ToShortTimeString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descontar: ", _standardFont)); clCarac.BorderWidth = 0; clDescrip = new PdfPCell(new Phrase(desc, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Observaciones: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Observacion, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descuento con ayudante: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].DtoConAyudante.ToString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descuento sin ayudante: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].DtoSinAyudante.ToString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); document.Add(tblBuenaPractica); document.Close(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-disposition", "inline; filename=" + dir + ".pdf"); Response.TransmitFile(dir + ".pdf"); Response.Flush(); //Process process = new Process(); //process.StartInfo.UseShellExecute = true; //process.StartInfo.FileName = dir + ".pdf"; //process.Start(); //string openWindowScript = string.Format("window.open({0}, '_blank');", dir + ".pdf"); ////ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), openWindowScript, true); //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), Guid.NewGuid().ToString(), openWindowScript, true); //ScriptManager.RegisterStartupScript(this, typeof(string), "New Window", "window.open(" + dir + ".pdf" + ")", true); } catch (Exception ex) { throw ex; } }
private void GenerarPDF(string dir, int id) { try { IBuenasPracticasDominio dominio = IoC.GetObjectDominio <Dominio.Interfaces.Dominio.IBuenasPracticasDominio>(); //IoC.GetObjectDominio<Dominio.Interfaces.Dominio.Guia.IDestinoGuiaDominio>().GetAgenciasDestino(); IList <BuenasPracticasCompleto> lista = new List <BuenasPracticasCompleto>(); lista = dominio.GetBuenasPracticasCompletoSEL(DateTime.Now.AddDays(-1), DateTime.Now, id); Document document = new Document(); PdfWriter.GetInstance(document, new FileStream(dir + ".pdf", FileMode.OpenOrCreate)); document.Open(); document.Add(new Paragraph("NO CONFORMIDAD DE BUENAS PRACTICAS EMITIDA")); document.Add(Chunk.NEWLINE); PdfPTable tblBuenaPractica = new PdfPTable(2); tblBuenaPractica.WidthPercentage = 100; iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); PdfPCell clCarac = new PdfPCell(new Phrase("Caracteristica", _standardFont)); clCarac.BorderWidth = 0; clCarac.BorderWidthBottom = 0.75f; PdfPCell clDescrip = new PdfPCell(new Phrase("Descripcion", _standardFont)); clDescrip.BorderWidth = 0; clDescrip.BorderWidthBottom = 0.75f; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Movil: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.ddlMoviles.SelectedValue, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Responsable: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtResponsable.Text, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Dominio: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtDominio.Text, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Chofer: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtChofer.Text, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Buena Practica: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.ddlBP.SelectedItem.Text, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); //clCarac = new PdfPCell(new Phrase("Observaciones: ", _standardFont)); //clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservaciones.Text, _standardFont)); //clDescrip.BorderWidth = 0; //tblBuenaPractica.AddCell(clCarac); //tblBuenaPractica.AddCell(clDescrip); string desc = ""; // if (this.chDescontar.Checked) if (lista[0].Descontar) { desc = "Si"; } else { desc = "No"; } clCarac = new PdfPCell(new Phrase("Parte Nro.: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblParteNro.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].BuenasPracticasEmisionID.ToString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Movil: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblBuenaPracticaMovilSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Numero, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Dominio: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblDominioBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Dominio, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Responsable: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblResponsableBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Chofer, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Buena Practica: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblBuenaPracticaDescripcion.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Descrip, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Emitida Por: ", _standardFont)); clCarac.BorderWidth = 0; // clDescrip = new PdfPCell(new Phrase(this.lblUsuarioBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Usuario, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Fecha Emision: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.lblFechaBuenaPracticaEmision.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].FechaEmision.Value.ToShortDateString() + " " + lista[0].FechaEmision.Value.ToShortTimeString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descontar: ", _standardFont)); clCarac.BorderWidth = 0; clDescrip = new PdfPCell(new Phrase(desc, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Observaciones: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].Observacion, _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descuento con ayudante: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].DtoConAyudante.ToString(), _standardFont)); clDescrip.BorderWidth = 0; tblBuenaPractica.AddCell(clCarac); tblBuenaPractica.AddCell(clDescrip); clCarac = new PdfPCell(new Phrase("Descuento sin ayudante: ", _standardFont)); clCarac.BorderWidth = 0; //clDescrip = new PdfPCell(new Phrase(this.txtObservacionesSel.Text, _standardFont)); clDescrip = new PdfPCell(new Phrase(lista[0].DtoSinAyudante.ToString(), _standardFont)); clDescrip.BorderWidth = 0; document.Add(tblBuenaPractica); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph(" ")); document.Add(new Paragraph("NO CONFORMIDAD DE BUENAS PRACTICAS EMITIDA")); document.Add(Chunk.NEWLINE); document.Add(tblBuenaPractica); document.Close(); this.Session["Dir"] = dir + ".pdf"; //Process process = new Process(); //process.StartInfo.UseShellExecute = true; //process.StartInfo.FileName = dir + ".pdf"; //process.Start(); } catch (Exception ex) { throw ex; } }