protected void gv_scheduler_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { for (int indiceColonna = 1; indiceColonna <= listaRisorse.Count; indiceColonna++) { string idRisorsa = (e.Row.Cells[indiceColonna].Text.Trim()); Tipologica risorsaCorrente = Tipologie.getRisorsaById(int.Parse(idRisorsa)); string colore = Utility.getParametroDaTipologica(risorsaCorrente, "color"); e.Row.Cells[indiceColonna].Attributes.Add("style", "background-color:" + colore + ";font-size:10pt;text-align:center;"); e.Row.Cells[indiceColonna].Text = risorsaCorrente.nome; } } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[0].Attributes.Add("style", "font-weight:bold;background-color:#FDEDB5;"); for (int indiceColonna = 1; indiceColonna <= listaRisorse.Count; indiceColonna++) { if (!string.IsNullOrEmpty(e.Row.Cells[indiceColonna].Text.Trim())) { DatiAgenda datoAgendaCorrente = Tipologie.getDatiAgendaById(int.Parse(e.Row.Cells[indiceColonna].Text.Trim())); string colore = Utility.getParametroDaTipologica(Tipologie.getStatoById(datoAgendaCorrente.id_stato), "color"); string descrizione = datoAgendaCorrente.descrizione; e.Row.Cells[indiceColonna].Text = descrizione; e.Row.Cells[indiceColonna].Attributes.Add("style", "font-weight:bold;background-color:" + colore); } } e.Row.Attributes.Add("style", "text-align:center;"); } }
protected void btnOKModificaNote_Click(object sender, EventArgs e) { NoteOfferta noteOfferta = (NoteOfferta)ViewState["NoteOfferta"]; noteOfferta.Banca = ddl_Banca.SelectedValue; noteOfferta.Pagamento = 30; // int.Parse(tbMod_Pagamento.Text); //int.Parse(ComboMod_Pagamento.SelectedValue); noteOfferta.NotaPagamento = tbMod_Pagamento.Text.Trim(); noteOfferta.Consegna = txt_Consegna.Text; noteOfferta.Note = txt_Note.Text.Trim(); Offerta_BLL.Instance.AggiornaNoteOfferta(noteOfferta); //RichiediOperazionePopup("SAVE_PDF_OFFERTA"); //DivFramePdf.Visible = true; //framePdf.Visible = true; DatiAgenda eventoSel = (DatiAgenda)ViewState["eventoSelezionato"]; Esito esito = popolaPannelloRiepilogo(eventoSel); ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaNote", script: "javascript: aggiornaRiepilogo()", addScriptTags: true); ScriptManager.RegisterStartupScript(Page, typeof(Page), "chiudiModificaNote", script: "javascript: document.getElementById('panelModificaNote').style.display='none'", addScriptTags: true); // FACCIO REFRESH SUL FRAME CHE VISUALIZZA IL PDF IN MODO DA VEDERE GLI AGGIORNAMENTI IN TEMPO REALE ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdf.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); }
public List <int> GetTenderImpiegatiInPeriodo(DatiAgenda eventoDaControllare, ref Esito esito) { DateTime dataInizio = eventoDaControllare.data_inizio_impegno; DateTime dataFine = eventoDaControllare.data_fine_impegno; int idEventoDaControllare = eventoDaControllare.id; return(Agenda_DAL.Instance.GetTenderImpiegatiInPeriodo(dataInizio, dataFine, idEventoDaControllare, ref esito)); }
public Esito AggiornaEvento(DatiAgenda evento, List <string> listaIdTender) { Esito esito = new Esito(); esito = Agenda_DAL.Instance.AggiornaEvento(evento, listaIdTender); return(esito); }
public Esito CreaEvento(DatiAgenda evento, List <string> listaIdTender, NoteOfferta noteOfferta) { Esito esito = new Esito(); esito = Agenda_DAL.Instance.CreaEvento(evento, listaIdTender, noteOfferta); return(esito); }
protected void cbCopriImporti_CheckedChanged(object sender, EventArgs e) { DatiAgenda eventoSel = (DatiAgenda)ViewState["eventoSelezionato"]; Esito esito = popolaPannelloRiepilogo(eventoSel); ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaNote", script: "javascript: aggiornaRiepilogo()", addScriptTags: true); ScriptManager.RegisterStartupScript(Page, typeof(Page), "chiudiModificaNote", script: "javascript: document.getElementById('panelModificaNote').style.display='none'", addScriptTags: true); // FACCIO REFRESH SUL FRAME CHE VISUALIZZA IL PDF IN MODO DA VEDERE GLI AGGIORNAMENTI IN TEMPO REALE ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdf.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true); }
private DataTable CreateDataTable(DateTime data) { DataTable table = new DataTable(); #region intestazione tabella DataColumn column; column = new DataColumn(); column.DataType = typeof(string); column.ColumnName = " "; table.Columns.Add(column); foreach (Tipologica risorsa in listaRisorse) { column = new DataColumn(); column.DataType = typeof(string); column.ColumnName = risorsa.id.ToString(); // inserisco id risorsa per poi formattare la cella in RowDataBound table.Columns.Add(column); } #endregion #region dati agenda for (int indiceRiga = 0; indiceRiga < 31; indiceRiga++) { DataRow row = table.NewRow(); DateTime dataRiga = data.AddDays(indiceRiga); row[0] = dataRiga.ToString("dd/MM/yyyy"); int indiceColonna = 1; foreach (Tipologica risorsa in listaRisorse) { List <DatiAgenda> datiAgendaFiltrati = listaDatiAgenda.Where(x => x.data_inizio <= dataRiga && x.data_fine >= dataRiga && x.id_risorsa == risorsa.id).ToList <DatiAgenda>(); if (datiAgendaFiltrati.Count == 1) { DatiAgenda datoCorrente = datiAgendaFiltrati.FirstOrDefault(); row[indiceColonna++] = datoCorrente.id.ToString(); // inserisco id datoAgenda per poi formattare la cella in RowDataBound } else { row[indiceColonna++] = " "; } //row[indiceColonna++] = listaDatiAgenda.Where(x => x.data_inizio <= dataRiga && x.data_fine >= dataRiga && x.id_risorsa == risorsa.id).Count() > 0 ? "X" : " "; } table.Rows.Add(row); } #endregion return(table); }
public Esito CreaOggettoSalvataggio(ref DatiAgenda datiAgenda) { Esito esito = new Esito(); bool campoObbligatorio = datiAgenda.id_stato != Stato.Instance.STATO_RIPOSO; datiAgenda.data_inizio_lavorazione = BasePage.ValidaCampo(txt_DataInizioLavorazione, DateTime.MinValue, true, ref esito); datiAgenda.data_fine_lavorazione = BasePage.ValidaCampo(txt_DataFineLavorazione, DateTime.MinValue, true, ref esito); datiAgenda.durata_lavorazione = BasePage.ValidaCampo(txt_DurataLavorazione, 0, campoObbligatorio, ref esito); datiAgenda.id_colonne_agenda = BasePage.ValidaCampo(ddl_Risorse, hf_Risorse, 0, true, ref esito); datiAgenda.id_tipologia = BasePage.ValidaCampo(ddl_Tipologie, hf_Tipologie, 0, campoObbligatorio, ref esito); datiAgenda.id_cliente = BasePage.ValidaCampo(ddl_Clienti, hf_Clienti, 0, campoObbligatorio, ref esito); datiAgenda.durata_viaggio_andata = BasePage.ValidaCampo(txt_DurataViaggioAndata, 0, campoObbligatorio, ref esito); datiAgenda.durata_viaggio_ritorno = BasePage.ValidaCampo(txt_DurataViaggioRitorno, 0, campoObbligatorio, ref esito); datiAgenda.data_inizio_impegno = BasePage.ValidaCampo(txt_DataInizioImpegno, DateTime.MinValue, campoObbligatorio, ref esito); datiAgenda.data_fine_impegno = BasePage.ValidaCampo(txt_DataFineImpegno, DateTime.MinValue, campoObbligatorio, ref esito); datiAgenda.produzione = BasePage.ValidaCampo(txt_Produzione, "", campoObbligatorio, ref esito); datiAgenda.lavorazione = BasePage.ValidaCampo(txt_Lavorazione, "", false, ref esito); datiAgenda.indirizzo = BasePage.ValidaCampo(txt_Indirizzo, "", false, ref esito); datiAgenda.luogo = BasePage.ValidaCampo(txt_Luogo, "", campoObbligatorio, ref esito); datiAgenda.nota = BasePage.ValidaCampo(tb_Nota, "", false, ref esito); return(esito); }
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 EliminaLavorazione(DatiAgenda evento) { Esito esito = Agenda_DAL.Instance.EliminaLavorazione(evento); return(esito); }
public Esito popolaPannelloRiepilogo(DatiAgenda eventoSelezionato) { Esito esito = new Esito(); //AbilitaVisualizzazioneStampa(false); lbl_Data.Text = lbl_DataStampa.Text = DateTime.Now.ToString("dd/MM/yyyy ore HH:mm"); lbl_Produzione.Text = lbl_ProduzioneStampa.Text = eventoSelezionato.produzione; lbl_Lavorazione.Text = lbl_LavorazioneStampa.Text = eventoSelezionato.lavorazione; lbl_DataLavorazione.Text = lbl_DataLavorazioneStampa.Text = eventoSelezionato.data_inizio_lavorazione.ToString("dd/MM/yyyy"); Anag_Clienti_Fornitori cliente = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(eventoSelezionato.id_cliente, ref esito); if (esito.Codice != Esito.ESITO_OK) { basePage.ShowError(esito.Descrizione); return(esito); } lbl_Cliente.Text = lbl_ClienteStampa.Text = cliente.RagioneSociale; lbl_IndirizzoCliente.Text = lbl_IndirizzoClienteStampa.Text = cliente.TipoIndirizzoOperativo + " " + cliente.IndirizzoOperativo + " " + cliente.NumeroCivicoOperativo + " " + cliente.CapOperativo + " " + cliente.ComuneOperativo + " " + cliente.ProvinciaOperativo; lbl_PIvaCliente.Text = lbl_PIvaClienteStampa.Text = string.IsNullOrEmpty(cliente.PartitaIva) ? cliente.CodiceFiscale : cliente.PartitaIva; lbl_CodLavorazione.Text = lbl_CodLavorazioneStampa.Text = eventoSelezionato.codice_lavoro; List <DatiArticoli> listaDatiArticoli = RichiediListaArticoli().Where(x => x.Stampa).ToList <DatiArticoli>(); gvArticoli.DataSource = listaDatiArticoli; try { gvArticoli.DataBind(); } catch (Exception e) { basePage.ShowError(e.Message); } decimal totPrezzo = 0; decimal totIVA = 0; foreach (DatiArticoli art in listaDatiArticoli) { totPrezzo += art.Prezzo * art.Quantita; totIVA += (art.Prezzo * art.Iva / 100) * art.Quantita; } totale.Text = totaleStampa.Text = string.Format("{0:N2}", totPrezzo); totaleIVA.Text = totaleIVAStampa.Text = string.Format("{0:N2}", totIVA); totaleEuro.Text = totaleEuroStampa.Text = string.Format("{0:N2}", totPrezzo + totIVA); int idTipoProtocollo = UtilityTipologiche.getElementByNome(UtilityTipologiche.caricaTipologica(EnumTipologiche.TIPO_PROTOCOLLO), "offerta", ref esito).id; List <Protocolli> listaProtocolli = Protocolli_BLL.Instance.getProtocolliByCodLavIdTipoProtocollo(eventoSelezionato.codice_lavoro, idTipoProtocollo, ref esito, true); string protocollo = listaProtocolli.Count == 0 ? "N.D." : listaProtocolli.First().Numero_protocollo + "-" + eventoSelezionato.codice_lavoro; lbl_Protocollo.Text = lbl_ProtocolloStampa.Text = protocollo; NoteOfferta noteOfferta = Offerta_BLL.Instance.getNoteOffertaByIdDatiAgenda(eventoSelezionato.id, ref esito); // se non viene trovata una notaOfferta (vecchi eventi) viene creata e salvata if (noteOfferta.Id == 0) { List <DatiBancari> datiBancari = Config_BLL.Instance.getListaDatiBancari(ref esito); noteOfferta = new NoteOfferta { Id_dati_agenda = eventoSelezionato.id, Banca = datiBancari[0].DatiCompleti, Pagamento = cliente.Pagamento, NotaPagamento = cliente.NotaPagamento, Consegna = cliente.TipoIndirizzoLegale + " " + cliente.IndirizzoLegale + " " + cliente.NumeroCivicoLegale + Environment.NewLine + cliente.CapLegale + " " + cliente.ComuneLegale + " " + cliente.ProvinciaLegale + " " }; // "Unicredit Banca: IBAN: IT39H0200805198000103515620", Pagamento = cliente.Pagamento, Consegna = cliente.TipoIndirizzoLegale + " " + cliente.IndirizzoLegale + " " + cliente.NumeroCivicoLegale + " " + cliente.CapLegale + " " + cliente.ProvinciaLegale + " " }; Offerta_BLL.Instance.CreaNoteOfferta(noteOfferta, ref esito); } ViewState["NoteOfferta"] = noteOfferta; val_bancaSchermo.Text = val_bancaStampa.Text = noteOfferta.Banca; // val_pagamentoSchermo.Text = val_pagamentoStampa.Text = noteOfferta.NotaPagamento; // + " gg DFFM"; val_consegnaSchermo.Text = val_consegnaStampa.Text = noteOfferta.Consegna; //ddl_Banca.SelectedValue = noteOfferta.Banca;// commentato perché se non trova l'elemento (e può succedere) schioda txt_Consegna.Text = noteOfferta.Consegna; //try //{ // ComboMod_Pagamento.SelectedValue = noteOfferta.Pagamento.ToString(); //} //catch (Exception ex) //{ // ComboMod_Pagamento.Items.Add(new ListItem(noteOfferta.Pagamento.ToString(), noteOfferta.Pagamento.ToString())); // ComboMod_Pagamento.SelectedValue = noteOfferta.Pagamento.ToString(); //} //tbMod_Pagamento.Text = noteOfferta.Pagamento.ToString(); tbMod_Pagamento.Text = noteOfferta.NotaPagamento.ToString(); //ComboMod_Pagamento.Text = noteOfferta.Pagamento.ToString(); if (string.IsNullOrEmpty(noteOfferta.Note)) { //note.Text = ""; note.Text = ""; txt_Note.Text = ""; } else { //note.Text = noteOfferta.Note.Trim(); note.Text = BasePage.trimNote(noteOfferta.Note, 5); note.Text = note.Text.Trim().Replace("\n", "<br/>"); txt_Note.Text = noteOfferta.Note.Trim(); } DivFramePdf.Visible = true; framePdf.Visible = true; 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 void PopolaAppuntamento() { Esito esito = new Esito(); DatiAgenda evento = SessionManager.EventoSelezionato; string[] elencoProduzioni = Agenda_BLL.Instance.CaricaElencoProduzioni(ref esito).ToArray(); string[] elencoLavorazioni = Agenda_BLL.Instance.CaricaElencoLavorazioni(ref esito).ToArray(); ScriptManager.RegisterStartupScript(this, this.GetType(), "setElenchi", "setElenchi(" + Newtonsoft.Json.JsonConvert.SerializeObject(elencoProduzioni) + ", " + Newtonsoft.Json.JsonConvert.SerializeObject(elencoLavorazioni) + ");", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "autocompletamento", "autocompletamento();", true); txt_DataInizioLavorazione.Text = evento.data_inizio_lavorazione.ToString("dd/MM/yyyy"); txt_DataFineLavorazione.Text = evento.data_fine_lavorazione == DateTime.MinValue ? "" : evento.data_fine_lavorazione.ToString("dd/MM/yyyy"); txt_DurataLavorazione.Text = evento.durata_lavorazione.ToString(); hf_Risorse.Value = evento.id_colonne_agenda.ToString(); ddl_Risorse.Text = ddl_Risorse.ToolTip = SessionManager.ListaRisorse.Where(x => x.id == evento.id_colonne_agenda).FirstOrDefault().nome; if (evento.id_tipologia == 0 || evento.id_tipologia == null) { hf_Tipologie.Value = ""; ddl_Tipologie.Text = "<seleziona>"; } else { hf_Tipologie.Value = evento.id_tipologia.ToString(); ddl_Tipologie.Text = ddl_Tipologie.ToolTip = SessionManager.ListaTipiTipologie.Where(x => x.id == evento.id_tipologia).FirstOrDefault().nome; } if (evento.id_cliente == 0) { hf_Clienti.Value = ""; ddl_Clienti.Text = "<seleziona>"; } else { hf_Clienti.Value = evento.id_cliente.ToString(); ddl_Clienti.Text = ddl_Clienti.ToolTip = SessionManager.ListaClientiFornitori.Where(x => x.Id == evento.id_cliente).FirstOrDefault().RagioneSociale; } //Inibito il cambiamento tra sottotipi (dipendente o unità esterna) per evitare di entrare in stato inconsistente //if (evento.id_stato != Stato.Instance.STATO_PREVISIONE_IMPEGNO && evento.id_stato != Stato.Instance.STATO_RIPOSO) if (evento.id_stato != Stato.Instance.STATO_RIPOSO) { List <ColonneAgenda> listaRisorseNoDipendenti = SessionManager.ListaRisorse.Where(x => x.sottotipo.ToUpper() != EnumSottotipiRisorse.DIPENDENTI.ToString()).ToList <ColonneAgenda>(); //elencoRisorse.InnerHtml = "<input class='form-control' id='filtroRisorse' type='text' placeholder='Cerca..'>"; basePage.PopolaDDLTipologica(elencoRisorse, listaRisorseNoDipendenti, "filtroRisorse"); } else { List <ColonneAgenda> listaRisorseSoloDipendenti = SessionManager.ListaRisorse.Where(x => x.sottotipo.ToUpper() == EnumSottotipiRisorse.DIPENDENTI.ToString()).ToList <ColonneAgenda>(); //elencoRisorse.InnerHtml = "<input class='form-control' id='filtroRisorse' type='text' placeholder='Cerca..'>"; basePage.PopolaDDLTipologica(elencoRisorse, listaRisorseSoloDipendenti, "filtroRisorse"); } txt_DurataViaggioAndata.Text = evento.durata_viaggio_andata.ToString(); txt_DurataViaggioRitorno.Text = evento.durata_viaggio_ritorno.ToString(); txt_DataInizioImpegno.Text = evento.data_inizio_impegno.ToString(); txt_DataFineImpegno.Text = evento.data_fine_impegno.ToString(); txt_Produzione.Text = evento.produzione; txt_Lavorazione.Text = evento.lavorazione; txt_Indirizzo.Text = evento.indirizzo; txt_Luogo.Text = evento.luogo; tb_Nota.Text = evento.nota; List <DatiTender> listaDatiTender = Dati_Tender_BLL.Instance.getDatiAgendaTenderByIdAgenda(evento.id, ref esito); ListaIdTender = (from tender in listaDatiTender select tender.IdTender.ToString()).ToList(); for (int i = 0; i < check_tender.Items.Count; i++) { if (listaDatiTender.Where(x => x.IdTender == int.Parse(check_tender.Items[i].Value)).ToList <DatiTender>().Count > 0) { check_tender.Items[i].Selected = true; } } }
public Esito GetListaDatiAgendaByFiltri(string dataLavorazione, string idTipologia, string idCliente, string produzione, string lavorazione, string luogo, string codiceLavoro, ref List <DatiAgenda> listaDatiAgenda) { Esito esito = new Esito(); string filtri = string.Empty; if (!string.IsNullOrEmpty(dataLavorazione)) { filtri += " and data_inizio_lavorazione = '" + dataLavorazione + "' "; } if (!string.IsNullOrEmpty(idTipologia)) { filtri += " and id_tipologia = " + idTipologia; } if (!string.IsNullOrEmpty(idCliente)) { filtri += " and id_cliente = " + idCliente; } if (!string.IsNullOrEmpty(produzione)) { filtri += " and produzione = '" + produzione + "' "; } if (!string.IsNullOrEmpty(lavorazione)) { filtri += " and lavorazione = '" + lavorazione + "' "; } if (!string.IsNullOrEmpty(luogo)) { filtri += " and luogo = '" + luogo + "' "; } if (!string.IsNullOrEmpty(codiceLavoro)) { filtri += " and codice_lavoro = '" + codiceLavoro + "'"; } try { using (SqlConnection con = new SqlConnection(sqlConstr)) { string query = "select * from tab_dati_agenda where id_stato > 1 " + filtri; query += " order by data_inizio_lavorazione desc"; using (SqlCommand cmd = new SqlCommand(query)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { foreach (DataRow riga in dt.Rows) { DatiAgenda datoAgenda = new DatiAgenda { id = riga.Field <int>("id"), id_colonne_agenda = riga.Field <int>("id_colonne_agenda"), id_stato = riga.Field <int>("id_stato"), data_inizio_lavorazione = riga["data_inizio_lavorazione"] != DBNull.Value ? riga.Field <DateTime>("data_inizio_lavorazione") : DateTime.MinValue, data_fine_lavorazione = riga["data_fine_lavorazione"] != DBNull.Value ? riga.Field <DateTime>("data_fine_lavorazione") : DateTime.MaxValue, durata_lavorazione = riga.Field <int>("durata_lavorazione"), id_tipologia = riga.Field <int?>("id_tipologia"), id_cliente = riga.Field <int>("id_cliente"), durata_viaggio_andata = riga.Field <int>("durata_viaggio_andata"), durata_viaggio_ritorno = riga.Field <int>("durata_viaggio_ritorno"), data_inizio_impegno = riga["data_inizio_impegno"] != DBNull.Value ? riga.Field <DateTime>("data_inizio_impegno") : DateTime.MinValue, data_fine_impegno = riga["data_fine_impegno"] != DBNull.Value ? riga.Field <DateTime>("data_fine_impegno") : DateTime.MaxValue, impegnoOrario = riga.Field <bool>("impegnoOrario"), impegnoOrario_da = riga.Field <string>("impegnoOrario_da"), impegnoOrario_a = riga.Field <string>("impegnoOrario_a"), produzione = riga.Field <string>("produzione"), lavorazione = riga.Field <string>("lavorazione"), indirizzo = riga.Field <string>("indirizzo"), luogo = riga.Field <string>("luogo"), codice_lavoro = riga.Field <string>("codice_lavoro"), nota = riga.Field <string>("nota") }; listaDatiAgenda.Add(datoAgenda); } } } } } } } catch (Exception ex) { esito.Codice = Esito.ESITO_KO_ERRORE_GENERICO; esito.Descrizione = "Offerta_DAL.cs - GetListaDatiAgendaByFiltri " + Environment.NewLine + ex.Message; log.Error(ex.Message + Environment.NewLine + ex.StackTrace); } return(esito); }
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); }