public static iText.Kernel.Colors.DeviceRgb MakeDarker(iText.Kernel.Colors.DeviceRgb rgbColor) { float r = rgbColor.GetColorValue()[0]; float g = rgbColor.GetColorValue()[1]; float b = rgbColor.GetColorValue()[2]; float v = Math.Max(r, Math.Max(g, b)); float multiplier = Math.Max(0f, (v - 0.33f) / v); r = multiplier * r; g = multiplier * g; b = multiplier * b; return(new iText.Kernel.Colors.DeviceRgb(r, g, b)); }
public static iText.Kernel.Colors.DeviceRgb MakeLighter(iText.Kernel.Colors.DeviceRgb rgbColor) { float r = rgbColor.GetColorValue()[0]; float g = rgbColor.GetColorValue()[1]; float b = rgbColor.GetColorValue()[2]; float v = Math.Max(r, Math.Max(g, b)); if (v == 0f) { return(new iText.Kernel.Colors.DeviceRgb(0x54, 0x54, 0x54)); } float multiplier = Math.Min(1f, v + 0.33f) / v; r = multiplier * r; g = multiplier * g; b = multiplier * b; return(new iText.Kernel.Colors.DeviceRgb(r, g, b)); }
public void HandleEvent(Event @event) { PdfDocumentEvent docEvent = (PdfDocumentEvent)@event; PdfPage page = docEvent.GetPage(); int pageNumber = docEvent.GetDocument().GetNumberOfPages(); var bgColor = ((SolidColorBrush)Pages[pageNumber - 1].Canvas.Background).Color; var pageColor = new iText.Kernel.Colors.DeviceRgb( Convert.ToInt32(bgColor.R), Convert.ToInt32(bgColor.G), Convert.ToInt32(bgColor.B) ); PdfCanvas canvas = new PdfCanvas(page); iText.Kernel.Geom.Rectangle rect = page.GetPageSize(); canvas.SaveState() .SetFillColor(pageColor) .Rectangle(rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight()) .FillStroke() .RestoreState(); }
//private void Helper_GeneralSummary(GridViewRow row) //{ // row.BackColor = Color.Gray; // row.Cells[0].HorizontalAlign = HorizontalAlign.Right; // row.Cells[0].Text = "<b>Totale</b>"; // row.Cells[1].Text = "<b>" + row.Cells[1].Text + "</b>"; // row.Cells[2].Text = "<b>" + row.Cells[2].Text + "</b>"; // row.Cells[3].Text = "<b>" + row.Cells[3].Text + "</b>"; // row.Cells[4].Text = "<b>" + row.Cells[4].Text + "</b>"; // row.Cells[5].Text = "<b>" + row.Cells[5].Text + "</b>"; // //row.Cells[6].Text = "<b>" + row.Cells[6].Text + "</b>"; //} protected void btnStampa_Click(object sender, EventArgs e) { try { Esito esito = new Esito(); DateTime dataInizio = DateTime.Parse(txt_DataInizio.Text); DateTime dataFine = DateTime.Parse(txt_DataFine.Text); string nominativo = txt_Nominativo.Text; string lavorazione = txt_Lavorazione.Text; string produzione = txt_Produzione.Text; bool soloFornitori = chk_Fornitore.Checked; List <DatiReport> listaDatiReport = Report_BLL.Instance.GetListaDatiReportCollaboratoriFornitori(dataInizio, dataFine, nominativo, lavorazione, produzione, soloFornitori, ref esito); Report_BLL.Instance.EliminaCollaboratoriImportoZero(ref listaDatiReport); if (esito.Codice == 0 && listaDatiReport != null && listaDatiReport.Count > 0) { // LEGGO I PARAMETRI DI VS Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA"); string pIvaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE"); string denominazioneVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO"); string toponimoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO"); string indirizzoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO"); string civicoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP"); string capVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA"); string cittaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA"); string provinciaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL"); string emailVs = cfAppo.valore; // export SU PDF string nomeFile = "Report_Collaboratori.pdf"; string pathReport = ConfigurationManager.AppSettings["PATH_DOCUMENTI_REPORT"] + nomeFile; string mapPathReport = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_REPORT"]) + nomeFile; //string prefissoUrl = Request.Url.Scheme + "://" + Request.Url.Authority; iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png")); PdfWriter wr = new PdfWriter(mapPathReport); PdfDocument doc = new PdfDocument(wr); doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate()); //doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4); Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4.Rotate(), false); document.SetMargins(50, 30, 50, 30); //iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(0, 225, 0); // COLORE BLU VIDEOSYSTEM iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243); //CICLO LISTA DATI REPORT int totCollaboratoriUtilizzati = 0; foreach (DatiReport collaboratore in listaDatiReport) { totCollaboratoriUtilizzati++; // AGGIUNGO TABLE PER LAYOUT INTESTAZIONE iText.Layout.Element.Table tbIntestazione = new iText.Layout.Element.Table(new float[] { 1, 9 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(100, 70).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); Cell cellaImmagine = new Cell().SetVerticalAlignment(iText.Layout.Properties.VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); cellaImmagine.Add(image); tbIntestazione.AddCell(cellaImmagine); iText.Layout.Element.Table tbIntestazioneDx = new iText.Layout.Element.Table(new float[] { 4, 6 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); Paragraph pTitolo = new Paragraph("Nome").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); Paragraph pValore = new Paragraph(collaboratore.NomeCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Qualifica").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(collaboratore.QualificaCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Indirizzo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(collaboratore.IndirizzoCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Città").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(collaboratore.CittaCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Telefono").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(collaboratore.TelefonoCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Cod.Fiscale/P.Iva").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(collaboratore.CodFiscaleCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); // AGGIUNGO INTESTAZIONE COLLABORATORE tbIntestazione.AddCell(tbIntestazioneDx).SetBorder(iText.Layout.Borders.Border.NO_BORDER); document.Add(tbIntestazione); Paragraph pSpazio = new Paragraph(" "); document.Add(pSpazio); Paragraph pLuogoData = new Paragraph(cittaVs + ", " + DateTime.Today.ToLongDateString()); document.Add(pLuogoData); document.Add(pSpazio); // CREAZIONE GRIGLIA iText.Layout.Element.Table tbGrigla = new iText.Layout.Element.Table(new float[] { 67, 138, 120, 100, 100, 55, 50, 50, 50, 50 }).SetWidth(780).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetFixedLayout(); Paragraph pGriglia; Cell cellaGriglia; // INTESTAZIONE GRIGLIA pGriglia = new Paragraph("Data").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Lavorazione").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Produzione").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Cliente").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Descrizione").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Assunz.").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Mista").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Rimb. KM").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Rit. Acconto").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Fattura").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); //pGriglia = new Paragraph("Diaria").SetFontSize(10); //cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); //cellaGriglia.Add(pGriglia); //tbGrigla.AddHeaderCell(cellaGriglia); // TOTALI PARZIALI decimal fattura = 0; decimal ritenutaAcconto = 0; decimal assunzione = 0; decimal mista = 0; decimal rimborsoKm = 0; //int diaria = 0; foreach (DatiFiscaliLavorazione datiFiscali in collaboratore.ListaDatiFiscali) { pGriglia = new Paragraph(datiFiscali.DataLavorazione.ToShortDateString()).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(datiFiscali.Lavorazione).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(datiFiscali.Produzione).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(datiFiscali.Cliente).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(datiFiscali.Descrizione).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); assunzione += datiFiscali.Assunzione; pGriglia = new Paragraph(datiFiscali.Assunzione.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); mista += datiFiscali.Mista; pGriglia = new Paragraph(datiFiscali.Mista.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); rimborsoKm += datiFiscali.RimborsoKm; pGriglia = new Paragraph(datiFiscali.RimborsoKm.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); ritenutaAcconto += datiFiscali.RitenutaAcconto; pGriglia = new Paragraph(datiFiscali.RitenutaAcconto.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); fattura += datiFiscali.Fattura; pGriglia = new Paragraph(datiFiscali.Fattura.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); //diaria += datiFiscali.Diaria; //pGriglia = new Paragraph(datiFiscali.Diaria.ToString("###")).SetFontSize(9); //cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); //cellaGriglia.Add(pGriglia); //tbGrigla.AddCell(cellaGriglia); } pGriglia = new Paragraph("TOTALI").SetFontSize(9); cellaGriglia = new Cell(1, 5).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(assunzione.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(mista.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(rimborsoKm.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(ritenutaAcconto.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(fattura.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); //pGriglia = new Paragraph(diaria.ToString("##0")).SetFontSize(9); //cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); //cellaGriglia.Add(pGriglia); //tbGrigla.AddCell(cellaGriglia); // AGGIUNGO TABELLA document.Add(tbGrigla); if (totCollaboratoriUtilizzati < listaDatiReport.Count) { // AGGIUNGO SALTO PAGINA document.Add(new AreaBreak()); } } int n = doc.GetNumberOfPages(); iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize(); // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA for (int i = 1; i <= n; i++) { //AGGIUNGO NUM.PAGINA document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); //AGGIUNGO FOOTER document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER), pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); } // CHIUDO IL PDF document.Flush(); document.Close(); wr.Close(); btnRicerca_Click(null, null); // CREO STRINGA PER IL JAVASCRIPT DI VISUALIZZAZIONE if (System.IO.File.Exists(mapPathReport)) { Page page = HttpContext.Current.Handler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "apriPdf", script: "window.open('" + pathReport.Replace("~", "") + "')", addScriptTags: true); } else { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "Il File " + pathReport.Replace("~", "") + " non è stato creato correttamente!"; BasePage p = new BasePage(); p.ShowError(esito.Descrizione); } } } catch (Exception ex) { BasePage p = new BasePage(); p.ShowError(ex.Message + " " + ex.StackTrace); } }
public Esito popolaPannelloFattura(DatiAgenda eventoSelezionato) { Esito esito = new Esito(); try { if (eventoSelezionato != null && eventoSelezionato.LavorazioneCorrente != null) { // LEGGO I PARAMETRI DI VS Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA"); string pIvaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE"); string denominazioneVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO"); string toponimoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO"); string indirizzoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO"); string civicoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP"); string capVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA"); string cittaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA"); string provinciaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL"); string emailVs = cfAppo.valore; //List<DatiArticoliLavorazione> listaArticoliLavorazione = eventoSelezionato.LavorazioneCorrente.ListaArticoliLavorazione.Where(x => x.Stampa).OrderBy(x => x.Fattura).ToList<DatiArticoliLavorazione>(); List <DatiArticoliLavorazione> listaArticoliLavorazione = eventoSelezionato.LavorazioneCorrente.ListaArticoliLavorazione.Where(x => x.Stampa).ToList <DatiArticoliLavorazione>(); if (listaArticoliLavorazione != null) { Protocolli protocolloFattura = new Protocolli(); int idTipoProtocollo = UtilityTipologiche.getElementByNome(UtilityTipologiche.caricaTipologica(EnumTipologiche.TIPO_PROTOCOLLO), "Fattura", ref esito).id; List <Protocolli> listaProtocolli = Protocolli_BLL.Instance.getProtocolliByCodLavIdTipoProtocollo(eventoSelezionato.codice_lavoro, idTipoProtocollo, ref esito, true); string numeroProtocollo = ""; string numeroFattura = ""; if (listaProtocolli.Count == 0) { numeroProtocollo = Protocolli_BLL.Instance.getNumeroProtocollo(); // ESTRAPOLO IL NUMERO FATTURA DALLA TABELLA TAB_NUMERO_FATTURA numeroFattura = Protocolli_BLL.Instance.getNumeroFattura(); } else { bool trovato = false; foreach (Protocolli protocollo in listaProtocolli) { if (protocollo.Destinatario == "Cliente") { //protocolloFattura = listaProtocolli.First(); numeroProtocollo = protocollo.Numero_protocollo; numeroFattura = protocollo.Protocollo_riferimento; protocolloFattura = protocollo; trovato = true; break; } } if (!trovato) { numeroProtocollo = Protocolli_BLL.Instance.getNumeroProtocollo(); // ESTRAPOLO IL NUMERO FATTURA DALLA TABELLA TAB_NUMERO_FATTURA numeroFattura = Protocolli_BLL.Instance.getNumeroFattura(); listaProtocolli.Clear(); } } // GESTIONE NOMI FILE PDF //string nomeFile = "Fattura_" + eventoSelezionato.codice_lavoro + ".pdf"; string nomeFile = "Fattura_" + numeroFattura + ".pdf"; string pathFattura = ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"] + nomeFile; string mapPathFattura = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"]) + nomeFile; //string prefissoUrl = Request.Url.Scheme + "://" + Request.Url.Authority; iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png")); iText.IO.Image.ImageData imageDNV = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/DNV_2008_ITA2.jpg")); PdfWriter wr = new PdfWriter(mapPathFattura); PdfDocument doc = new PdfDocument(wr); doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4); //Document document = new Document(doc); Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4, false); document.SetMargins(245, 30, 110, 30); // ESTRAPOLO IL CLIENTE Anag_Clienti_Fornitori cliente = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(eventoSelezionato.id_cliente, ref esito); Paragraph pSpazio = new Paragraph(" "); document.Add(pSpazio); // CREAZIONE GRIGLIA iText.Layout.Element.Table tbGrigla = new iText.Layout.Element.Table(new float[] { 80, 70, 180, 70, 30, 30, 70 }).SetWidth(530).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetFixedLayout(); Paragraph pGriglia; Cell cellaGriglia; // COLORE BLU VIDEOSYSTEM iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243); // INTESTAZIONE FATTURA pGriglia = new Paragraph("Fattura").SetFontSize(10).SetBold(); cellaGriglia = new Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph(numeroFattura + " Rif.Lav. " + eventoSelezionato.codice_lavoro).SetFontSize(10).SetBold(); cellaGriglia = new iText.Layout.Element.Cell(1, 2).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); //pGriglia = new Paragraph("").SetFontSize(10); //cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); //cellaGriglia.Add(pGriglia); //tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Rif.Prot. " + numeroProtocollo).SetFontSize(10).SetBold(); cellaGriglia = new iText.Layout.Element.Cell(1, 4).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); // INTESTAZIONE GRIGLIA pGriglia = new Paragraph("Codice").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Descrizione Offerta").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell(1, 2).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Prezzo").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Qta").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Iva").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); pGriglia = new Paragraph("Totale").SetFontSize(10); cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddHeaderCell(cellaGriglia); decimal totPrezzo = 0; decimal totIVA = 0; // CICLO GLI ARTICOLI //foreach (DatiArticoli da in listaDatiArticoli) foreach (DatiArticoliLavorazione da in listaArticoliLavorazione) { // CALCOLO I TOTALI //totPrezzo += da.Prezzo * da.Quantita; totPrezzo += da.Prezzo * 1; //totIVA += (da.Prezzo * da.Iva / 100) * da.Quantita; totIVA += (da.Prezzo * da.Iva / 100) * 1; string descrizione = da.Descrizione; string descrizioneLunga = da.DescrizioneLunga; pGriglia = new Paragraph(descrizione).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); if (da.Consuntivo == true) { //descrizione = "(c)" + descrizione; //descrizioneLunga = "(Consuntivo)" + Environment.NewLine + descrizioneLunga; Text firstDesc = new Text("(Consuntivo)" + Environment.NewLine).SetFontSize(9).SetBold(); Text secondDesc = new Text(descrizioneLunga).SetFontSize(9); pGriglia = new Paragraph().Add(firstDesc).Add(secondDesc); } else { pGriglia = new Paragraph(descrizioneLunga).SetFontSize(9); } cellaGriglia = new Cell(1, 2).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(da.Prezzo.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); //pGriglia = new Paragraph(da.Quantita.ToString("##0")).SetFontSize(9); pGriglia = new Paragraph(1.ToString("##0")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(da.Iva.ToString("##")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); //decimal totale = da.Prezzo * da.Quantita; decimal totale = da.Prezzo * 1; pGriglia = new Paragraph(totale.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); } // AGGIUNGO UNO SPAZIO pGriglia = new Paragraph(" ").SetFontSize(9); cellaGriglia = new Cell(1, 7).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); // ESTRAPOLO NOTEOFFERTA NoteOfferta noteOfferta = Offerta_BLL.Instance.getNoteOffertaByIdDatiAgenda(eventoSelezionato.id, ref esito); // NOTE Text first = new Text("Note:").SetFontSize(9).SetBold(); //Text second = new Text(Environment.NewLine + "Gli articoli con la dicitura 'Cons' sono da ritenersi a CONSUNTIVO" + Environment.NewLine + noteOfferta.Note.Trim()).SetFontSize(9); Text second = new Text(Environment.NewLine + noteOfferta.Note.Trim()).SetFontSize(9); Paragraph paragraphNote = new Paragraph().Add(first).Add(second); cellaGriglia = new iText.Layout.Element.Cell(3, 3).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10); cellaGriglia.Add(paragraphNote); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph("Imponibile").SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell(1, 3).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(totPrezzo.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); // TOTALE IVA pGriglia = new Paragraph("i.v.a.").SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell(1, 3).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph(totIVA.ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); // TOTALE EURO pGriglia = new Paragraph("Totale Euro").SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell(1, 3).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); pGriglia = new Paragraph((totPrezzo + totIVA).ToString("###,##0.00")).SetFontSize(9); cellaGriglia = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold(); cellaGriglia.Add(pGriglia); tbGrigla.AddCell(cellaGriglia); document.Add(tbGrigla); //iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(1).GetPageSize(); int n = doc.GetNumberOfPages(); iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize(); // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA for (int i = 1; i <= n; i++) { // AGGIUNGO LOGO iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(90, 80).SetFixedPosition(i, 30, 740); document.Add(image); // CREAZIONE GRIGLIA INFORMAZIONI iText.Layout.Element.Table tbGriglaInfo = new iText.Layout.Element.Table(new float[] { 70, 230 }).SetWidth(300).SetFixedPosition(i, 30, 640, 300); Paragraph pGrigliaInfo = new Paragraph(cittaVs).SetFontSize(9).SetBold(); iText.Layout.Element.Cell cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); //pGrigliaInfo = new Paragraph(DateTime.Today.ToLongDateString()).SetFontSize(9); if (string.IsNullOrEmpty(tbDataProtocollo.Text)) { tbDataProtocollo.Text = eventoSelezionato.data_inizio_lavorazione.ToShortDateString(); } pGrigliaInfo = new Paragraph(Convert.ToDateTime(tbDataProtocollo.Text).ToLongDateString()).SetFontSize(9); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph("Produzione:").SetFontSize(9).SetBold(); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph(eventoSelezionato.produzione).SetFontSize(9); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph("Lavorazione:").SetFontSize(9).SetBold(); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph(eventoSelezionato.lavorazione).SetFontSize(9); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph("Data Lav.ne:").SetFontSize(9).SetBold(); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); pGrigliaInfo = new Paragraph(eventoSelezionato.data_inizio_lavorazione.ToString("dd/MM/yyyy")).SetFontSize(9); cellaGrigliaInfo = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaInfo.Add(pGrigliaInfo); tbGriglaInfo.AddCell(cellaGrigliaInfo); document.Add(tbGriglaInfo); // CREAZIONE GRIGLIA DESTINATARIO iText.Layout.Element.Table tbGriglaDest = new iText.Layout.Element.Table(new float[] { 70, 230 }).SetWidth(300).SetFixedPosition(i, 350, 650, 300); Paragraph pGrigliaDest = new Paragraph("Spettabile").SetFontSize(9).SetBold(); iText.Layout.Element.Cell cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); pGrigliaDest = new Paragraph(cliente.RagioneSociale).SetFontSize(9); cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); // INDIRIZZO DESTINATARIO pGrigliaDest = new Paragraph("Indirizzo").SetFontSize(9).SetBold(); cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); //pGrigliaDest = new Paragraph(cliente.TipoIndirizzoOperativo + " " + cliente.IndirizzoOperativo + " " + cliente.NumeroCivicoOperativo + Environment.NewLine + cliente.CapOperativo + " " + cliente.ComuneOperativo + " " + cliente.ProvinciaOperativo).SetFontSize(9); //cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); //cellaGrigliaDest.Add(pGrigliaDest); //tbGriglaDest.AddCell(cellaGrigliaDest); pGrigliaDest = new Paragraph(cliente.TipoIndirizzoLegale + " " + cliente.IndirizzoLegale + " " + cliente.NumeroCivicoLegale + Environment.NewLine + cliente.CapLegale + " " + cliente.ComuneLegale + " " + cliente.ProvinciaLegale).SetFontSize(9); cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); // PARTITA IVA DESTINATARIO pGrigliaDest = new Paragraph("P.Iva/C.F.").SetFontSize(9).SetBold(); cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); string pIvaCF = cliente.PartitaIva; if (string.IsNullOrEmpty(pIvaCF)) { pIvaCF = cliente.CodiceFiscale; } pGrigliaDest = new Paragraph(pIvaCF).SetFontSize(9); cellaGrigliaDest = new iText.Layout.Element.Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaDest.Add(pGrigliaDest); tbGriglaDest.AddCell(cellaGrigliaDest); document.Add(tbGriglaDest); //document.Add(pSpazio); //document.Add(pSpazio); // CREAZIONE INTESTAZIONE GRIGLIA //iText.Layout.Element.Table tbGriglaInt = new iText.Layout.Element.Table(new float[] { 80, 50, 200, 80, 20, 20, 80 }).SetWidth(530).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetFixedPosition(i, 30, 595, 530); ; //document.Add(tbGriglaInt); // AGGIUNGO LOGO DNV iText.Layout.Element.Image logoDnv = new iText.Layout.Element.Image(imageDNV).ScaleAbsolute(40, 40).SetFixedPosition(i, 518, 8); document.Add(logoDnv); //AGGIUNGO NUM.PAGINA document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); //AGGIUNGO FOOTER document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER), pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); if (i == n) { // NELL'ULTIMA PAGINA AGGIUNGO LA GRIGLIA CON LE NOTE E IL TIMBRO // CREAZIONE GRIGLIA iText.Layout.Element.Table tbGriglaNoteFooter = new iText.Layout.Element.Table(new float[] { 80, 70, 180, 70, 30, 30, 70 }).SetWidth(530).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.LIGHT_GRAY, 10).SetFixedPosition(30, 50, 530).SetFixedLayout(); // PRIMA RIGA GRIGLIA NOTE FOOTER Paragraph pGrigliaNoteFooter = new Paragraph("Banca").SetFontSize(9); iText.Layout.Element.Cell cellaGrigliaNoteFooter = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph(noteOfferta.Banca).SetFontSize(9); //cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1,2).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.LIGHT_GRAY, 10).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(2); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 2).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorderRight(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 2, 50)).SetBorderTop(iText.Layout.Borders.Border.NO_BORDER).SetBorderLeft(iText.Layout.Borders.Border.NO_BORDER).SetBorderBottom(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph("Timbro e firma per accettazione").SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 4).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); // SECONDA RIGA GRIGLIA NOTE FOOTER pGrigliaNoteFooter = new Paragraph("Pagamento").SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph(noteOfferta.NotaPagamento).SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 2).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorderRight(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 2, 50)).SetBorderTop(iText.Layout.Borders.Border.NO_BORDER).SetBorderLeft(iText.Layout.Borders.Border.NO_BORDER).SetBorderBottom(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph(" ").SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 4).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); // TERZA RIGA GRIGLIA NOTE FOOTER pGrigliaNoteFooter = new Paragraph("Consegna").SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph(noteOfferta.Consegna.Replace("\r\n", " ")).SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 2).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorderRight(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 2, 50)).SetBorderTop(iText.Layout.Borders.Border.NO_BORDER).SetBorderLeft(iText.Layout.Borders.Border.NO_BORDER).SetBorderBottom(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); pGrigliaNoteFooter = new Paragraph(" ").SetFontSize(9); cellaGrigliaNoteFooter = new iText.Layout.Element.Cell(1, 4).SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5); cellaGrigliaNoteFooter.Add(pGrigliaNoteFooter); tbGriglaNoteFooter.AddCell(cellaGrigliaNoteFooter); document.Add(tbGriglaNoteFooter); } } document.Close(); wr.Close(); if (File.Exists(mapPathFattura)) { // SE FILE OK INSERISCO O AGGIORNO PROTOCOLLO DI FATTURA if (listaProtocolli.Count == 0) { //INSERISCO protocolloFattura.Attivo = true; protocolloFattura.Cliente = cliente.RagioneSociale.Trim(); protocolloFattura.Codice_lavoro = eventoSelezionato.codice_lavoro; protocolloFattura.Data_inizio_lavorazione = eventoSelezionato.data_inizio_impegno; //protocolloFattura.Data_protocollo = DateTime.Today; protocolloFattura.Data_protocollo = Convert.ToDateTime(tbDataProtocollo.Text); protocolloFattura.Descrizione = "Fattura"; protocolloFattura.Id_cliente = eventoSelezionato.id_cliente; protocolloFattura.Id_tipo_protocollo = idTipoProtocollo; protocolloFattura.Lavorazione = eventoSelezionato.lavorazione; protocolloFattura.PathDocumento = Path.GetFileName(mapPathFattura); protocolloFattura.Produzione = eventoSelezionato.produzione; protocolloFattura.Protocollo_riferimento = numeroFattura; protocolloFattura.Numero_protocollo = numeroProtocollo; protocolloFattura.Pregresso = false; protocolloFattura.Destinatario = "Cliente"; int idProtPianoEsterno = Protocolli_BLL.Instance.CreaProtocollo(protocolloFattura, ref esito); ViewState["idProtocollo"] = idProtPianoEsterno; } else { // AGGIORNO protocolloFattura.PathDocumento = Path.GetFileName(mapPathFattura); protocolloFattura.Data_protocollo = Convert.ToDateTime(tbDataProtocollo.Text); esito = Protocolli_BLL.Instance.AggiornaProtocollo(protocolloFattura); ViewState["idProtocollo"] = protocolloFattura.Id; } ViewState["importo"] = totPrezzo; ViewState["iva"] = listaArticoliLavorazione[0].Iva;// totIVA; ViewState["importoIva"] = totPrezzo + totIVA; ViewState["banca"] = noteOfferta.Banca; ViewState["numeroDocumento"] = eventoSelezionato.codice_lavoro; framePdfFattura.Attributes.Remove("src"); framePdfFattura.Attributes.Add("src", pathFattura.Replace("~", "")); DivFramePdfFattura.Visible = true; framePdfFattura.Visible = true; ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdfFattura.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); btnStampaFattura.Attributes.Add("onclick", "window.open('" + pathFattura.Replace("~", "") + "');"); //} } else { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "Il File " + pathFattura.Replace("~", "") + " non è stato creato correttamente!"; } } } } catch (Exception ex) { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "popolaPannelloFattura(DatiAgenda eventoSelezionato) " + ex.Message + Environment.NewLine + ex.StackTrace; } return(esito); }
public Esito PopolaPannelloNotaSpese(DatiAgenda eventoSelezionato, FiguraProfessionale figuraProfessionaleSelezionata) { Esito esito = new Esito(); try { if (eventoSelezionato != null && eventoSelezionato.LavorazioneCorrente != null) { #region LEGGO I PARAMETRI DI VS Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA"); string pIvaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE"); string denominazioneVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO"); string toponimoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO"); string indirizzoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO"); string civicoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP"); string capVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA"); string cittaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA"); string provinciaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL"); string emailVs = cfAppo.valore; #endregion List <DatiPianoEsternoLavorazione> listaDatiPianoEsternoLavorazione = eventoSelezionato.LavorazioneCorrente.ListaDatiPianoEsternoLavorazione; if (listaDatiPianoEsternoLavorazione != null) { string nomeFile = "NotaSpese.pdf"; string pathNotaSpese = ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"] + nomeFile; string mapPathNotaSpese = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"]) + nomeFile; //string prefissoUrl = Request.Url.Scheme + "://" + Request.Url.Authority; iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png")); PdfWriter wr = new PdfWriter(mapPathNotaSpese); PdfDocument doc = new PdfDocument(wr); doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate()); Document document = new Document(doc); document.SetMargins(50, 30, 50, 30); // COLORE BLU VIDEOSYSTEM iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243); Paragraph pIntestazioneNotaSpese = new Paragraph("Nota Spese di: " + figuraProfessionaleSelezionata.Nome + " " + figuraProfessionaleSelezionata.Cognome); pIntestazioneNotaSpese.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); pIntestazioneNotaSpese.SetFontSize(20); pIntestazioneNotaSpese.SetBold(); document.Add(pIntestazioneNotaSpese); // AGGIUNGO TABLE PER LAYOUT INTESTAZIONE iText.Layout.Element.Table tbIntestazione = new iText.Layout.Element.Table(new float[] { 1, 9 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(90, 80).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); Cell cellaImmagine = new Cell().SetVerticalAlignment(iText.Layout.Properties.VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); cellaImmagine.Add(image); tbIntestazione.AddCell(cellaImmagine); iText.Layout.Element.Table tbIntestazioneDx = new iText.Layout.Element.Table(new float[] { 2, 3, 2, 3 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); Anag_Clienti_Fornitori cliente = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(eventoSelezionato.id_cliente, ref esito); Paragraph pTitolo = new Paragraph("Cliente").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); Paragraph pValore = new Paragraph(cliente.RagioneSociale.Trim()).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Referente").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); string nomeReferente = ""; if (eventoSelezionato.LavorazioneCorrente.IdReferente != null) { Anag_Referente_Clienti_Fornitori referente = Anag_Referente_Clienti_Fornitori_BLL.Instance.getReferenteById(ref esito, Convert.ToInt32(eventoSelezionato.LavorazioneCorrente.IdReferente.Value)); nomeReferente = referente.Nome + " " + referente.Cognome; } pValore = new Paragraph(nomeReferente).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Produzione").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(eventoSelezionato.produzione).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Capotecnico").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); string nomeCapotecnico = ""; if (eventoSelezionato.LavorazioneCorrente.IdCapoTecnico != null) { Anag_Collaboratori coll = Anag_Collaboratori_BLL.Instance.getCollaboratoreById(eventoSelezionato.LavorazioneCorrente.IdCapoTecnico.Value, ref esito); nomeCapotecnico = coll.Nome + " " + coll.Cognome; } pValore = new Paragraph(nomeCapotecnico).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Lavorazione").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.lavorazione).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Data Inizio").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.data_inizio_impegno.ToShortDateString()).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Luogo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.luogo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Data Lavoraz.").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.data_inizio_lavorazione.ToShortDateString()).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Indirizzo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.indirizzo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Cod.Lavor.").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.codice_lavoro).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazione.AddCell(tbIntestazioneDx).SetBorder(iText.Layout.Borders.Border.NO_BORDER); document.Add(tbIntestazione); Paragraph pSpazio = new Paragraph(" "); document.Add(pSpazio); Paragraph pLuogoData = new Paragraph(cittaVs + ", " + DateTime.Today.ToLongDateString()); pLuogoData.SetFontSize(8); document.Add(pLuogoData); document.Add(pSpazio); // INTESTAZIONE GRIGLIA iText.Layout.Element.Table table = new iText.Layout.Element.Table(new float[] { 90, 70, 70, 70, 70, 70, 70, 70, 200 }).SetWidth(780); Border bordoDoppio = new DoubleBorder(1); Cell cella = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER); table.AddHeaderCell(cella); Paragraph intestazioneMain = new Paragraph("Tipologia di pagamento").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); cella = new Cell(1, 3).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); cella.SetBorderLeft(bordoDoppio); cella.Add(intestazioneMain); table.AddHeaderCell(cella); intestazioneMain = new Paragraph("Costi in Euro").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); cella = new Cell(1, 5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); cella.SetBorderLeft(bordoDoppio); cella.Add(intestazioneMain); table.AddHeaderCell(cella); Paragraph intestazione = new Paragraph("Data").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Sofid").SetFontSize(10).SetBold().SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); cella = new Cell().SetBorderLeft(bordoDoppio); cella.Add(intestazione); table.AddHeaderCell(cella).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Carta").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Contanti").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Carburante").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); cella = new Cell().SetBorderLeft(bordoDoppio); cella.Add(intestazione); table.AddHeaderCell(cella).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Albergo").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Trasporti").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Pasti").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); intestazione = new Paragraph("Varie").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); // CELLE VUOTE for (int i = 0; i < 12; i++) { table.AddCell(new Cell().SetHeight(15)); cella = new Cell().SetBorderLeft(bordoDoppio); table.AddCell(cella); table.AddCell(" "); table.AddCell(" "); cella = new Cell().SetBorderLeft(bordoDoppio); table.AddCell(cella); table.AddCell(" "); table.AddCell(" "); table.AddCell(" "); table.AddCell(" "); } document.Add(table); Paragraph pFirma = new Paragraph("in fede"); pFirma.SetFontSize(9); pFirma.SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); pFirma.SetMarginRight(90); pFirma.SetMarginTop(13); document.Add(pFirma); iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(1).GetPageSize(); int n = doc.GetNumberOfPages(); // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA for (int i = 1; i <= n; i++) { //AGGIUNGO NUM.PAGINA document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); //AGGIUNGO FOOTER document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER), pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); } //document.Flush(); document.Close(); wr.Close(); framePdfNotaSpese.Attributes.Remove("src"); framePdfNotaSpese.Attributes.Add("src", pathNotaSpese.Replace("~", "")); DivFramePdfNotaSpese.Visible = true; framePdfNotaSpese.Visible = true; ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdfNotaSpese.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); btnStampaNotaSpese.Attributes.Add("onclick", "window.open('" + pathNotaSpese.Replace("~", "") + "');"); } } } catch (Exception ex) { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "PopolaPannelloNotaSpese(DatiAgenda eventoSelezionato, FiguraProfessionale figuraProfessionaleSelezionata) " + ex.Message + Environment.NewLine + ex.StackTrace; } return(esito); }
public Legend(String label, iText.Kernel.Colors.DeviceRgb colour) { Label = label; Colour = colour; }
public Legend() { Label = ""; Colour = new iText.Kernel.Colors.DeviceRgb(); }
internal static iText.Kernel.Colors.Color ToITextColor(System.Drawing.Color color) { var dRGB = new iText.Kernel.Colors.DeviceRgb(color.R, color.G, color.B); return(dRGB); }
public Esito popolaPannelloPianoEsterno(DatiAgenda eventoSelezionato) { Esito esito = new Esito(); try { if (eventoSelezionato != null && eventoSelezionato.LavorazioneCorrente != null) { // LEGGO I PARAMETRI DI VS Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA"); string pIvaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE"); string denominazioneVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO"); string toponimoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO"); string indirizzoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO"); string civicoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP"); string capVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA"); string cittaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA"); string provinciaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL"); string emailVs = cfAppo.valore; List <DatiPianoEsternoLavorazione> listaDatiPianoEsternoLavorazione = eventoSelezionato.LavorazioneCorrente.ListaDatiPianoEsternoLavorazione; if (listaDatiPianoEsternoLavorazione != null) { Protocolli protocolloPianoEsterno = new Protocolli(); int idTipoProtocollo = UtilityTipologiche.getElementByNome(UtilityTipologiche.caricaTipologica(EnumTipologiche.TIPO_PROTOCOLLO), "Piano Esterno", ref esito).id; List <Protocolli> listaProtocolli = Protocolli_BLL.Instance.getProtocolliByCodLavIdTipoProtocollo(eventoSelezionato.codice_lavoro, idTipoProtocollo, ref esito, true); string numeroProtocollo = ""; if (listaProtocolli.Count == 0) { numeroProtocollo = Protocolli_BLL.Instance.getNumeroProtocollo(); } else { protocolloPianoEsterno = listaProtocolli.First(); numeroProtocollo = protocolloPianoEsterno.Numero_protocollo; } // GESTIONE NOMI FILE PDF //string nomeFile = "PianoEsterno_" + eventoSelezionato.LavorazioneCorrente.Id.ToString() + ".pdf"; //string nomeFile = "PianoEsterno_" + numeroProtocollo + ".pdf"; string nomeFile = "PianoEsterno_" + eventoSelezionato.codice_lavoro + ".pdf"; string pathPianoEsterno = ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"] + nomeFile; string mapPathPianoEsterno = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"]) + nomeFile; //string prefissoUrl = Request.Url.Scheme + "://" + Request.Url.Authority; iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png")); PdfWriter wr = new PdfWriter(mapPathPianoEsterno); PdfDocument doc = new PdfDocument(wr); doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate()); //doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4); //Document document = new Document(doc); Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4.Rotate(), false); //document.SetMargins(90, 30, 50, 30); document.SetMargins(50, 30, 50, 30); //iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(0, 225, 0); // COLORE BLU VIDEOSYSTEM iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243); // AGGIUNGO TABLE PER LAYOUT INTESTAZIONE iText.Layout.Element.Table tbIntestazione = new iText.Layout.Element.Table(new float[] { 1, 9 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); //iText.Layout.Element.Table tbIntestazione = new iText.Layout.Element.Table(3).UseAllAvailableWidth(); iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(90, 80).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); Cell cellaImmagine = new Cell().SetVerticalAlignment(iText.Layout.Properties.VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER); cellaImmagine.Add(image); tbIntestazione.AddCell(cellaImmagine); iText.Layout.Element.Table tbIntestazioneDx = new iText.Layout.Element.Table(new float[] { 2, 3, 2, 3 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER); Anag_Clienti_Fornitori cliente = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(eventoSelezionato.id_cliente, ref esito); Paragraph pTitolo = new Paragraph("Cliente").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); Paragraph pValore = new Paragraph(cliente.RagioneSociale.Trim()).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Referente").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); string nomeReferente = ""; if (eventoSelezionato.LavorazioneCorrente.IdReferente != null) { Anag_Referente_Clienti_Fornitori referente = Anag_Referente_Clienti_Fornitori_BLL.Instance.getReferenteById(ref esito, Convert.ToInt32(eventoSelezionato.LavorazioneCorrente.IdReferente.Value)); nomeReferente = referente.Nome + " " + referente.Cognome; } pValore = new Paragraph(nomeReferente).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Produzione").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pValore = new Paragraph(eventoSelezionato.produzione).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Capotecnico").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); string nomeCapotecnico = ""; if (eventoSelezionato.LavorazioneCorrente.IdCapoTecnico != null) { Anag_Collaboratori coll = Anag_Collaboratori_BLL.Instance.getCollaboratoreById(eventoSelezionato.LavorazioneCorrente.IdCapoTecnico.Value, ref esito); nomeCapotecnico = coll.Nome + " " + coll.Cognome; } pValore = new Paragraph(nomeCapotecnico).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Lavorazione").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.lavorazione).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Data Inizio").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.data_inizio_impegno.ToShortDateString()).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Luogo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.luogo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Data Lavoraz.").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.data_inizio_lavorazione.ToShortDateString()).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Indirizzo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.indirizzo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); pTitolo = new Paragraph("Cod.Lavor.").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(eventoSelezionato.codice_lavoro).SetBorder(iText.Layout.Borders.Border.NO_BORDER); iText.Layout.Element.Cell cellaNote = new iText.Layout.Element.Cell(2, 4).SetBorder(iText.Layout.Borders.Border.NO_BORDER); string notePianoEsterno = ""; if (eventoSelezionato.LavorazioneCorrente.NotePianoEsterno != null) { notePianoEsterno = eventoSelezionato.LavorazioneCorrente.NotePianoEsterno; } Paragraph pNotePiano = new Paragraph(notePianoEsterno.Trim()).SetFontSize(10).SetBorder(iText.Layout.Borders.Border.NO_BORDER); cellaNote.Add(pNotePiano).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazioneDx.AddCell(cellaNote).SetBorder(iText.Layout.Borders.Border.NO_BORDER); tbIntestazione.AddCell(tbIntestazioneDx).SetBorder(iText.Layout.Borders.Border.NO_BORDER); document.Add(tbIntestazione); Paragraph pSpazio = new Paragraph(" "); document.Add(pSpazio); Paragraph pLuogoData = new Paragraph(cittaVs + ", " + DateTime.Today.ToLongDateString()); document.Add(pLuogoData); document.Add(pSpazio); // INTESTAZIONE GRIGLIA iText.Layout.Element.Table table = new iText.Layout.Element.Table(10).UseAllAvailableWidth(); //.SetBorderTop(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.ORANGE, 5)).SetBorderBottom(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.YELLOW, 5)).SetBorderLeft(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.GREEN, 5)).SetBorderRight(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.RED, 5)); Paragraph intestazione = new Paragraph("Data").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Personale").SetFontSize(10).SetBold().SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Qualifica").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Intervento").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Telefono").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Città").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Albergo").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Diaria").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Orario").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Note").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); string dataConfronto = ""; foreach (DatiPianoEsternoLavorazione dpe in listaDatiPianoEsternoLavorazione) { string collaboratoreFornitore = ""; string telefono = ""; string qualifica = ""; string citta = ""; string descrizioneArticoloAssociato = ""; if (dpe.IdCollaboratori != null) { Anag_Collaboratori coll = Anag_Collaboratori_BLL.Instance.getCollaboratoreById(dpe.IdCollaboratori.Value, ref esito); collaboratoreFornitore = coll.Cognome.Trim() + " " + coll.Nome.Trim(); // prendo descrizione da datiArticoliLavorazione filtrando per data, idCollaboratore e idLavorazione DatiArticoliLavorazione articoloAssociato = SessionManager.EventoSelezionato.LavorazioneCorrente.ListaArticoliLavorazione.FirstOrDefault(x => x.IdCollaboratori == coll.Id && x.Data == dpe.Data); if (articoloAssociato != null) { descrizioneArticoloAssociato = articoloAssociato.Descrizione; } FiguraProfessionale fp = coll.CreaFiguraProfessionale(descrizioneArticoloAssociato); //if (fp!=null && !string.IsNullOrEmpty(fp.ElencoQualifiche)) qualifica = fp.ElencoQualifiche; if (fp != null && !string.IsNullOrEmpty(fp.DescrizioneArticoloAssociato)) { qualifica = fp.DescrizioneArticoloAssociato; } if (fp != null && !string.IsNullOrEmpty(fp.Telefono)) { telefono = fp.Telefono; } if (telefono.StartsWith("0039")) { telefono = telefono.Substring(4); } if (telefono.StartsWith("+39")) { telefono = telefono.Substring(3); } if (fp != null && !string.IsNullOrEmpty(fp.Citta)) { citta = fp.Citta; } } else if (dpe.IdFornitori != null) { Anag_Clienti_Fornitori clienteFornitore = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(dpe.IdFornitori.Value, ref esito); collaboratoreFornitore = clienteFornitore.RagioneSociale.Trim(); // prendo descrizione da datiArticoliLavorazione filtrando per data, idFornitore e idLavorazione DatiArticoliLavorazione articoloAssociato = SessionManager.EventoSelezionato.LavorazioneCorrente.ListaArticoliLavorazione.FirstOrDefault(x => x.IdFornitori == clienteFornitore.Id && x.Data == dpe.Data); if (articoloAssociato != null) { descrizioneArticoloAssociato = articoloAssociato.Descrizione; } FiguraProfessionale fp = clienteFornitore.CreaFiguraProfessionale(descrizioneArticoloAssociato); //if (fp != null && !string.IsNullOrEmpty(fp.ElencoQualifiche)) qualifica = fp.ElencoQualifiche; if (fp != null && !string.IsNullOrEmpty(fp.DescrizioneArticoloAssociato)) { qualifica = fp.DescrizioneArticoloAssociato; } if (fp != null && !string.IsNullOrEmpty(fp.Telefono)) { telefono = fp.Telefono; } if (fp != null && !string.IsNullOrEmpty(fp.Citta)) { citta = fp.Citta; } } string importoDiaria = "0,00"; if (dpe.ImportoDiaria != null) { importoDiaria = dpe.ImportoDiaria.Value.ToString("###,###.00"); } string nota = ""; if (!string.IsNullOrEmpty(dpe.Nota)) { nota = dpe.Nota; } string dataPiano = ""; if (dpe.Data != null) { dataPiano = dpe.Data.Value.ToShortDateString(); } // METTO SEPARATORE QUANDO CAMBIA DATA if (string.IsNullOrEmpty(dataConfronto)) { dataConfronto = dataPiano; } if (!string.IsNullOrEmpty(dataConfronto) && !dataConfronto.Equals(dataPiano)) { dataConfronto = dataPiano; Cell cellavuota = new Cell(2, 10).SetHeight(10f); table.AddCell(cellavuota); } string orario = ""; if (dpe.Orario != null) { orario = dpe.Orario.Value.ToShortTimeString(); } string intervento = ""; if (dpe.IdIntervento != null) { intervento = SessionManager.ListaTipiIntervento.FirstOrDefault(x => x.id == dpe.IdIntervento).nome; } string albergo = "no"; if (dpe.Albergo != null && dpe.Albergo == true) { albergo = "si"; } //Paragraph p = new Paragraph(dpe.Data.Value.ToLongDateString() + " " + orario + " " + collaboratoreFornitore + " " + nota).SetFontSize(8); //document.Add(p); table.AddCell(dataPiano).SetFontSize(8).SetFontSize(10); table.AddCell(collaboratoreFornitore); table.AddCell(qualifica).SetFontSize(8); table.AddCell(intervento).SetFontSize(8); table.AddCell(telefono).SetFontSize(8); table.AddCell(citta).SetFontSize(8); table.AddCell(albergo).SetFontSize(8); Paragraph pImportoDiaria = new Paragraph(importoDiaria).SetFontSize(8).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); table.AddCell(pImportoDiaria); table.AddCell(orario).SetFontSize(8); table.AddCell(nota).SetFontSize(8); } document.Add(table); //iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(1).GetPageSize(); int n = doc.GetNumberOfPages(); iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize(); // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA for (int i = 1; i <= n; i++) { // AGGIUNGO LOGO //iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(60, 60).SetFixedPosition(i, 20, pageSize.GetHeight() - 80); //document.Add(image); //AGGIUNGO NUM.PAGINA document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); //AGGIUNGO FOOTER document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER), pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); } document.Close(); wr.Close(); if (File.Exists(mapPathPianoEsterno)) { // SE FILE OK INSERISCO O AGGIORNO PROTOCOLLO DI TIPO PIANO ESTERNO if (listaProtocolli.Count == 0) { //INSERISCO protocolloPianoEsterno.Attivo = true; protocolloPianoEsterno.Cliente = cliente.RagioneSociale.Trim(); protocolloPianoEsterno.Codice_lavoro = eventoSelezionato.codice_lavoro; protocolloPianoEsterno.Data_inizio_lavorazione = eventoSelezionato.data_inizio_impegno; protocolloPianoEsterno.Data_protocollo = DateTime.Today; protocolloPianoEsterno.Descrizione = "Piano Esterno"; protocolloPianoEsterno.Id_cliente = eventoSelezionato.id_cliente; protocolloPianoEsterno.Id_tipo_protocollo = idTipoProtocollo; protocolloPianoEsterno.Lavorazione = eventoSelezionato.lavorazione; protocolloPianoEsterno.PathDocumento = Path.GetFileName(mapPathPianoEsterno); protocolloPianoEsterno.Produzione = eventoSelezionato.produzione; protocolloPianoEsterno.Protocollo_riferimento = ""; protocolloPianoEsterno.Numero_protocollo = numeroProtocollo; protocolloPianoEsterno.Pregresso = false; protocolloPianoEsterno.Destinatario = "Cliente"; int idProtPianoEsterno = Protocolli_BLL.Instance.CreaProtocollo(protocolloPianoEsterno, ref esito); } else { // AGGIORNO protocolloPianoEsterno.PathDocumento = Path.GetFileName(mapPathPianoEsterno); esito = Protocolli_BLL.Instance.AggiornaProtocollo(protocolloPianoEsterno); } //string nomeFileToDisplay = BaseStampa.Instance.AddPageNumber(mapPathPdfSenzaNumeroPagina, mapPianoEsterno, ref esito); //if (File.Exists(mapPathPdfSenzaNumeroPagina)) File.Delete(mapPathPdfSenzaNumeroPagina); //if (esito.codice == Esito.ESITO_OK) { framePdfPianoEsterno.Attributes.Remove("src"); framePdfPianoEsterno.Attributes.Add("src", pathPianoEsterno.Replace("~", "")); DivFramePdfPianoEsterno.Visible = true; framePdfPianoEsterno.Visible = true; ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdfPianoEsterno.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); btnStampaPianoEsterno.Attributes.Add("onclick", "window.open('" + pathPianoEsterno.Replace("~", "") + "');"); //} } else { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "Il File " + pathPianoEsterno.Replace("~", "") + " non è stato creato correttamente!"; } } } } catch (Exception ex) { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "popolaPannelloPianoEsterno(DatiAgenda eventoSelezionato) " + ex.Message + Environment.NewLine + ex.StackTrace; } return(esito); }
public Esito popolaPannelloGiornata() { Esito esito = new Esito(); try { // LEGGO I PARAMETRI DI VS Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA"); string pIvaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE"); string denominazioneVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO"); string toponimoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO"); string indirizzoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO"); string civicoVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP"); string capVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA"); string cittaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA"); string provinciaVs = cfAppo.valore; cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL"); string emailVs = cfAppo.valore; // GESTIONE NOMI FILE PDF string nomeFile = "RiepilogoGiornata.pdf"; string pathGiornata = ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"] + nomeFile; string mapPathGiornata = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"]) + nomeFile; iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png")); iText.IO.Image.ImageData imageDNV = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/DNV_2008_ITA2.jpg")); PdfWriter wr = new PdfWriter(mapPathGiornata); PdfDocument doc = new PdfDocument(wr); doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate()); //Document document = new Document(doc); Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4.Rotate(), false); // IMPOSTO LA DATA DI OGGI SE PRIMA ELABORAZIONE if (string.IsNullOrEmpty(tbDataElaborazione.Text.Trim())) { tbDataElaborazione.Text = DateTime.Today.ToShortDateString(); } document.SetMargins(90, 35, 50, 35); Paragraph pSpazio = new Paragraph(""); document.Add(pSpazio); // COLORE BLU VIDEOSYSTEM iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243); DateTime dataTmp = Convert.ToDateTime(tbDataElaborazione.Text.Trim()); string sDataTmp = dataTmp.ToString("yyyy-MM-dd") + "T00:00:00.000"; string queryRicerca = "select dal.descrizione as qualifica,ac.cognome as cognome_operatore, ac.nome as nome_operatore, da.codice_lavoro,produzione,lavorazione " + //", da.durata_lavorazione as Durata , ca.nome,ts.nome,tt.nome " + //", ac.cognome as cognome_operatore,ac.nome as nome_operatore, dal.descrizioneLunga " + "from[dbo].[tab_dati_agenda] da " + "left join tipo_colonne_agenda ca " + "on da.id_colonne_agenda = ca.id " + "left join tipo_stato ts " + "on da.id_stato = ts.id " + "left join tipo_tipologie tt " + "on da.id_tipologia = tt.id " + "left join dati_lavorazione dl " + "on dl.idDatiAgenda = da.id " + "left join dati_articoli_lavorazione dal " + "on dl.id = dal.idDatiLavorazione " + "left join anag_collaboratori ac " + "on dal.idCollaboratori = ac.id " + "where ac.cognome is not null and dal.descrizione<> 'Diaria' " + "and data_inizio_lavorazione <= '@dataElaborazione' and data_fine_lavorazione >= '@dataElaborazione' " + //"order by codice_lavoro, dal.descrizione, ac.cognome, ac.nome"; "group by dal.descrizione ,ac.cognome, ac.nome, da.codice_lavoro,produzione,lavorazione " + //"order by qualifica,ac.cognome, ac.nome, codice_lavoro"; "order by codice_lavoro,qualifica,ac.cognome, ac.nome"; queryRicerca = queryRicerca.Replace("@dataElaborazione", sDataTmp); esito = new Esito(); DataTable dtProtocolli = Base_DAL.GetDatiBySql(queryRicerca, ref esito); if (dtProtocolli != null && dtProtocolli.Rows != null && dtProtocolli.Rows.Count > 0) { // INTESTAZIONE GRIGLIA iText.Layout.Element.Table table = new iText.Layout.Element.Table(3).UseAllAvailableWidth(); //Paragraph intestazione = new Paragraph("Codice Lavoro").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); //table.AddHeaderCell(intestazione); //intestazione = new Paragraph("Produzione").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); //table.AddHeaderCell(intestazione); //intestazione = new Paragraph("Lavorazione").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); //table.AddHeaderCell(intestazione); Paragraph intestazione = new Paragraph("Qualifica").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Cognome").SetFontSize(10).SetBold().SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); intestazione = new Paragraph("Nome").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f); table.AddHeaderCell(intestazione); string codice_lavoro = ""; foreach (DataRow riga in dtProtocolli.Rows) { string qualifica = ""; string cognome = ""; string nome = ""; string produzione = ""; string lavorazione = ""; //Cell cellaQualifica = new Cell(); //if (!riga["qualifica"].ToString().ToUpper().Equals(qualifica.ToUpper())) //{ // Paragraph pQualifica = new Paragraph(riga["qualifica"].ToString()).SetFontSize(8).SetBold(); // cellaQualifica.Add(pQualifica); // qualifica = riga["qualifica"].ToString(); //} //else //{ // Paragraph pQualifica = new Paragraph("").SetFontSize(8).SetBold(); // cellaQualifica.Add(pQualifica); //} //table.AddCell(cellaQualifica); Cell cellaLavorazione = new Cell(1, 3); if (!riga["codice_lavoro"].ToString().ToUpper().Equals(codice_lavoro.ToUpper())) { if (riga["produzione"] != null) { produzione = riga["produzione"].ToString(); } if (riga["lavorazione"] != null) { lavorazione = riga["lavorazione"].ToString(); } Paragraph pCodiceLavoro = new Paragraph(riga["codice_lavoro"].ToString() + " - Produzione: " + produzione + " - Lavorazione: " + lavorazione).SetFontSize(10).SetBold(); cellaLavorazione.Add(pCodiceLavoro).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER); codice_lavoro = riga["codice_lavoro"].ToString(); table.AddCell(cellaLavorazione); } //else //{ // Paragraph pCodiceLavoro = new Paragraph("").SetFontSize(8).SetBold(); // cellaLavorazione.Add(pCodiceLavoro); //} //table.AddCell(cellaLavorazione); if (riga["qualifica"] != null) { qualifica = riga["qualifica"].ToString(); } if (riga["cognome_operatore"] != null) { cognome = riga["cognome_operatore"].ToString(); } if (riga["nome_operatore"] != null) { nome = riga["nome_operatore"].ToString(); } //table.AddCell(produzione).SetFontSize(8); //table.AddCell(lavorazione).SetFontSize(8); Cell cellaQualifica = new Cell(); Paragraph pQualifica = new Paragraph(qualifica).SetFontSize(9).SetBold(); cellaQualifica.Add(pQualifica).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT); table.AddCell(cellaQualifica); table.AddCell(cognome).SetFontSize(9); table.AddCell(nome).SetFontSize(9); } document.Add(table); } int n = doc.GetNumberOfPages(); iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize(); // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA for (int i = 1; i <= n; i++) { // AGGIUNGO LOGO iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(60, 60).SetFixedPosition(i, 20, pageSize.GetHeight() - 80); document.Add(image); // AGGIUNGO LOGO DNV iText.Layout.Element.Image logoDnv = new iText.Layout.Element.Image(imageDNV).ScaleAbsolute(40, 40).SetFixedPosition(i, 780, 8); document.Add(logoDnv); //AGGIUNGO NUM.PAGINA document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); // AGGIUNGO TITOLO document.ShowTextAligned(new Paragraph("OPERATORI IMPEGNATI PER IL " + tbDataElaborazione.Text.Trim()).SetFontSize(11), 400, pageSize.GetHeight() - 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); //AGGIUNGO FOOTER document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER), pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0); if (i == n) { // ULTIMA PAGINA } } document.Close(); wr.Close(); if (File.Exists(mapPathGiornata)) { framePdfGiornata.Attributes.Remove("src"); framePdfGiornata.Attributes.Add("src", pathGiornata.Replace("~", "")); DivFramePdfGiornata.Visible = true; framePdfGiornata.Visible = true; ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdfGiornata.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); btnStampaGiornata.Attributes.Add("onclick", "window.open('" + pathGiornata.Replace("~", "") + "');"); //} } else { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "Il File " + pathGiornata.Replace("~", "") + " non è stato creato correttamente!"; } } catch (Exception ex) { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "popolaPannelloGiornata() " + ex.Message + Environment.NewLine + ex.StackTrace; } return(esito); }