コード例 #1
0
        protected void btnAssociaFornitoreServer_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(tbMod_IdFornitore.Value) || tbMod_IdFornitore.Value.Equals("0"))
                {
                    tbMod_Fornitore.Text    = tbSearch_RagioneSociale.Text.Trim();
                    tbMod_IdFornitore.Value = null;
                    PanelFornitori.Visible  = false;
                }
                else
                {
                    Esito esito = new Esito();
                    Anag_Clienti_Fornitori fornitore = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(Convert.ToInt32(tbMod_IdFornitore.Value), ref esito);
                    if (esito.Codice != 0)
                    {
                        ShowError(esito.Descrizione);
                    }
                    else
                    {
                        tbMod_Fornitore.Text = fornitore.RagioneSociale;

                        PanelFornitori.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError("btnAssociaFornitoreServer_Click" + Environment.NewLine + ex.Message);
            }
        }
コード例 #2
0
        protected void btnSalva_Click(object sender, EventArgs e)
        {
            // SALVO MODIFICHE AZIENDA
            Esito esito = new Esito();
            Anag_Clienti_Fornitori azienda = CreaOggettoSalvataggio(ref esito);

            if (esito.Codice != Esito.ESITO_OK)
            {
                //panelErrore.Style.Remove("display");
                //lbl_MessaggioErrore.Text = "Controllare i campi evidenziati";
                basePage.ShowWarning("Controllare i campi evidenziati");
            }
            else
            {
                NascondiErroriValidazione();

                esito = Anag_Clienti_Fornitori_BLL.Instance.AggiornaAzienda(azienda, ((Anag_Utenti)Session[SessionManager.UTENTE]));


                if (esito.Codice != Esito.ESITO_OK)
                {
                    //panelErrore.Style.Remove("display");
                    //lbl_MessaggioErrore.Text = esito.descrizione;
                    basePage.ShowError(esito.Descrizione);
                }
                else
                {
                    SessionManager.ListaAnagraficheFornitori.Clear();
                    SessionManager.ListaClientiFornitori.Clear();
                    //SessionManager.ListaCittaFornitori.Clear();
                    EditAzienda_Click(null, null);
                }
            }
        }
コード例 #3
0
        private Anag_Clienti_Fornitori CreaOggettoSalvataggio(ref Esito esito)
        {
            Anag_Clienti_Fornitori azienda = new Anag_Clienti_Fornitori();

            try
            {
                if (ViewState["idAzienda"] == null || (string)ViewState["idAzienda"] == "")
                {
                    ViewState["idAzienda"] = 0;
                }

                azienda.Id = Convert.ToInt16(ViewState["idAzienda"].ToString());

                //azienda.Attivo = Convert.ToBoolean(BasePage.ValidaCampo(cbMod_Attivo, "true", false, ref esito));
                azienda.Attivo    = true;
                azienda.Cliente   = Convert.ToBoolean(BasePage.ValidaCampo(cbMod_Cliente, "true", false, ref esito));
                azienda.Fornitore = Convert.ToBoolean(BasePage.ValidaCampo(cbMod_Fornitore, "true", false, ref esito));

                azienda.RagioneSociale       = BasePage.ValidaCampo(tbMod_RagioneSociale, "", true, ref esito);
                azienda.CapLegale            = BasePage.ValidaCampo(tbMod_CapLegale, "", false, ref esito);
                azienda.CapOperativo         = BasePage.ValidaCampo(tbMod_CapOperativo, "", false, ref esito);
                azienda.CodiceFiscale        = BasePage.ValidaCampo(tbMod_CF, "", false, ref esito);
                azienda.CodiceIdentificativo = BasePage.ValidaCampo(tbMod_CodiceIdentificativo, "", false, ref esito);
                azienda.ComuneLegale         = BasePage.ValidaCampo(tbMod_ComuneLegale, "", false, ref esito);
                azienda.ComuneOperativo      = BasePage.ValidaCampo(tbMod_ComuneOperativo, "", false, ref esito);
                azienda.Email                 = BasePage.ValidaCampo(tbMod_Email, "", false, ref esito);
                azienda.Fax                   = BasePage.ValidaCampo(tbMod_Fax, "", false, ref esito);
                azienda.Iban                  = BasePage.ValidaCampo(tbMod_Iban, "", false, ref esito);
                azienda.IndirizzoLegale       = BasePage.ValidaCampo(tbMod_IndirizzoLegale, "", false, ref esito);
                azienda.IndirizzoOperativo    = BasePage.ValidaCampo(tbMod_IndirizzoOperativo, "", false, ref esito);
                azienda.NazioneLegale         = BasePage.ValidaCampo(tbMod_NazioneLegale, "", false, ref esito);
                azienda.NazioneOperativo      = BasePage.ValidaCampo(tbMod_NazioneOperativo, "", false, ref esito);
                azienda.Note                  = BasePage.ValidaCampo(tbMod_Note, "", false, ref esito);
                azienda.NumeroCivicoLegale    = BasePage.ValidaCampo(tbMod_CivicoLegale, "", false, ref esito);
                azienda.NumeroCivicoOperativo = BasePage.ValidaCampo(tbMod_CivicoOperativo, "", false, ref esito);

                string sPagamento = BasePage.ValidaCampo(cmbMod_Pagamento, "30", false, ref esito);
                azienda.Pagamento = Convert.ToInt16(sPagamento);

                azienda.PartitaIva             = BasePage.ValidaCampo(tbMod_PartitaIva, "", false, ref esito);
                azienda.Pec                    = BasePage.ValidaCampo(tbMod_Pec, "", false, ref esito);
                azienda.ProvinciaLegale        = BasePage.ValidaCampo(tbMod_ProvinciaLegale, "", false, ref esito);
                azienda.ProvinciaOperativo     = BasePage.ValidaCampo(tbMod_ProvinciaOperativo, "", false, ref esito);
                azienda.Telefono               = BasePage.ValidaCampo(tbMod_Telefono, "", false, ref esito);
                azienda.Tipo                   = cmbMod_TipoAzienda.SelectedValue;
                azienda.TipoIndirizzoLegale    = cmbMod_TipoIndirizzoLegale.SelectedValue;
                azienda.TipoIndirizzoOperativo = cmbMod_TipoIndirizzoOperativo.SelectedValue;
                azienda.WebSite                = BasePage.ValidaCampo(tbMod_WebSite, "", false, ref esito);
                azienda.NotaPagamento          = BasePage.ValidaCampo(tbMod_NotaPagamento, "", true, ref esito);

                return(azienda);
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
                return(azienda);
            }
        }
コード例 #4
0
        protected void btnAssociaClienteServer_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbMod_IdCliente.Value) || tbMod_IdCliente.Value.Equals("0"))
            {
                tbMod_Cliente.Text    = tbSearch_RagioneSociale.Text.Trim();
                tbMod_IdCliente.Value = null;
                PanelClienti.Visible  = false;
            }
            else
            {
                switch (ddlSceltaClienteCollaboratore.Text)
                {
                case "Cliente":

                    Esito esito = new Esito();
                    Anag_Clienti_Fornitori cliente = Anag_Clienti_Fornitori_BLL.Instance.getAziendaById(Convert.ToInt32(tbMod_IdCliente.Value), ref esito);
                    if (esito.Codice != 0)
                    {
                        ShowError(esito.Descrizione);
                    }
                    else
                    {
                        tbMod_Cliente.Text   = cliente.RagioneSociale;
                        PanelClienti.Visible = false;
                    }
                    break;

                case "Collaboratore":
                    esito = new Esito();
                    Anag_Collaboratori collaboratore = Anag_Collaboratori_BLL.Instance.getCollaboratoreById(Convert.ToInt32(tbMod_IdCliente.Value), ref esito);
                    if (esito.Codice != 0)
                    {
                        ShowError(esito.Descrizione);
                    }
                    else
                    {
                        tbMod_Cliente.Text    = collaboratore.Cognome + " " + collaboratore.Nome;
                        tbMod_IdCliente.Value = null;
                        PanelClienti.Visible  = false;
                    }
                    break;

                default:
                    break;
                }
            }
        }
コード例 #5
0
        public void PopolaDDLGenerico <T>(HtmlGenericControl listaDaPopolare, List <T> lista, string nomeFiltro)
        {
            //string elementi =  listaDaPopolare.InnerHtml;

            string elementi = "<input class='form-control' id='" + nomeFiltro + "' type='text' placeholder='Cerca..'><li class='dropdown-item'><a class='elemLista' href='#' val=''>&nbsp;</a></li>"; // aggiungo elemento vuoto

            if (lista is List <Anag_Clienti_Fornitori> )
            {
                foreach (T elem in lista)
                {
                    Anag_Clienti_Fornitori cliente = ConvertValue <Anag_Clienti_Fornitori>(elem);
                    elementi += "<li class='dropdown-item'><a class='elemLista' href='#' val='" + cliente.Id.ToString() + "'>" + cliente.RagioneSociale + "</a></li>";
                }
                listaDaPopolare.InnerHtml = elementi;
            }
            else if (lista is List <DatiLavorazione> )
            {
                foreach (T elem in lista)
                {
                    DatiLavorazione lavorazione = ConvertValue <DatiLavorazione>(elem);
                    elementi += "<li class='dropdown-item'><a class='elemLista' href='#' val='" + lavorazione.CodiceLavorazione + "'>" + lavorazione.CodiceLavorazione + " - " + lavorazione.DescrizioneLavorazione + "</a></li>";
                }
                listaDaPopolare.InnerHtml = elementi;
            }
            else if (lista is List <Protocolli> )
            {
                foreach (T elem in lista)
                {
                    Protocolli protocollo = ConvertValue <Protocolli>(elem);
                    elementi += "<li class='dropdown-item'><a class='elemLista' href='#' val='" + protocollo.Id.ToString() + "'>" + protocollo.Descrizione + "</a></li>";
                }
                listaDaPopolare.InnerHtml = elementi;
            }
            else if (lista is List <string> ) // caso generico di una lista di astringhe, quindi senza ID
            {
                foreach (T elem in lista)
                {
                    string stringa = ConvertValue <string>(elem);
                    elementi += "<li class='dropdown-item'><a class='elemLista' href='#' val='" + stringa + "'>" + stringa + "</a></li>";
                }
                listaDaPopolare.InnerHtml = elementi;
            }
        }
コード例 #6
0
        protected void btnConfermaInserimento_Click(object sender, EventArgs e)
        {
            // INSERISCO AZIENDA
            Esito esito = new Esito();
            Anag_Clienti_Fornitori azienda = CreaOggettoSalvataggio(ref esito);

            if (esito.Codice != Esito.ESITO_OK)
            {
                basePage.ShowError(esito.Descrizione);
                AttivaDisattivaModificaAzienda(false);
            }
            else
            {
                NascondiErroriValidazione();

                int iRet = Anag_Clienti_Fornitori_BLL.Instance.CreaAzienda(azienda, ((Anag_Utenti)Session[SessionManager.UTENTE]), ref esito);
                if (iRet > 0)
                {
                    // UNA VOLTA INSERITO CORRETTAMENTE PUO' ESSERE MODIFICATO
                    hf_idAzienda.Value      = iRet.ToString();
                    ViewState["idAzienda"]  = hf_idAzienda.Value;
                    hf_tipoOperazione.Value = "VISUALIZZAZIONE";
                }

                if (esito.Codice != Esito.ESITO_OK)
                {
                    basePage.ShowError(esito.Descrizione);
                }
                else
                {
                    SessionManager.ListaAnagraficheFornitori.Clear();
                    SessionManager.ListaClientiFornitori.Clear();
                    //SessionManager.ListaCittaFornitori.Clear();
                    EditAzienda_Click(null, null);
                }
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public Anag_Clienti_Fornitori GetAziendaById(int idAzienda, ref Esito esito)
        {
            Anag_Clienti_Fornitori azienda = new Anag_Clienti_Fornitori();

            try
            {
                using (SqlConnection con = new SqlConnection(sqlConstr))
                {
                    string query = "SELECT * FROM anag_clienti_fornitori where id = " + idAzienda.ToString();
                    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)
                                {
                                    azienda.Id                     = dt.Rows[0].Field <int>("id");
                                    azienda.Attivo                 = dt.Rows[0].Field <bool>("attivo");
                                    azienda.CapLegale              = dt.Rows[0].Field <string>("capLegale");
                                    azienda.CapOperativo           = dt.Rows[0].Field <string>("capOperativo");
                                    azienda.Cliente                = dt.Rows[0].Field <bool>("cliente");
                                    azienda.CodiceFiscale          = dt.Rows[0].Field <string>("codiceFiscale");
                                    azienda.CodiceIdentificativo   = dt.Rows[0].Field <string>("codiceIdentificativo");
                                    azienda.ComuneLegale           = dt.Rows[0].Field <string>("comuneLegale");
                                    azienda.ComuneOperativo        = dt.Rows[0].Field <string>("comuneOperativo");
                                    azienda.Email                  = dt.Rows[0].Field <string>("email");
                                    azienda.Telefono               = dt.Rows[0].Field <string>("telefono");
                                    azienda.Fax                    = dt.Rows[0].Field <string>("fax");
                                    azienda.Fornitore              = dt.Rows[0].Field <bool>("fornitore");
                                    azienda.Iban                   = dt.Rows[0].Field <string>("iban");
                                    azienda.TipoIndirizzoLegale    = dt.Rows[0].Field <string>("tipoIndirizzoLegale");
                                    azienda.IndirizzoLegale        = dt.Rows[0].Field <string>("indirizzoLegale");
                                    azienda.TipoIndirizzoOperativo = dt.Rows[0].Field <string>("tipoIndirizzoOperativo");
                                    azienda.IndirizzoOperativo     = dt.Rows[0].Field <string>("indirizzoOperativo");
                                    azienda.NazioneLegale          = dt.Rows[0].Field <string>("nazioneLegale");
                                    azienda.NazioneOperativo       = dt.Rows[0].Field <string>("nazioneOperativo");
                                    azienda.Note                   = dt.Rows[0].Field <string>("note");
                                    azienda.NumeroCivicoLegale     = dt.Rows[0].Field <string>("numeroCivicoLegale");
                                    azienda.NumeroCivicoOperativo  = dt.Rows[0].Field <string>("numeroCivicoOperativo");
                                    azienda.Pagamento              = dt.Rows[0].Field <int>("pagamento");
                                    azienda.PartitaIva             = dt.Rows[0].Field <string>("partitaIva");
                                    azienda.Pec                    = dt.Rows[0].Field <string>("pec");
                                    azienda.ProvinciaLegale        = dt.Rows[0].Field <string>("provinciaLegale");
                                    azienda.ProvinciaOperativo     = dt.Rows[0].Field <string>("provinciaOperativo");
                                    azienda.RagioneSociale         = dt.Rows[0].Field <string>("ragioneSociale");
                                    azienda.Tipo                   = dt.Rows[0].Field <string>("tipo");
                                    azienda.WebSite                = dt.Rows[0].Field <string>("webSite");
                                    azienda.NotaPagamento          = dt.Rows[0].Field <string>("notaPagamento");
                                    azienda.Referenti              = Anag_Referente_Clienti_Fornitori_DAL.Instance.getReferentiByIdAzienda(ref esito, azienda.Id);
                                }
                                else
                                {
                                    esito.Codice      = Esito.ESITO_KO_ERRORE_NO_RISULTATI;
                                    esito.Descrizione = "Azienda con id " + idAzienda.ToString() + " non trovato in tabella anag_clienti_fornitori ";
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
            }
            return(azienda);
        }
コード例 #9
0
        public Esito AggiornaAzienda(Anag_Clienti_Fornitori azienda, Anag_Utenti utente)
        {
            Esito esito = new Esito();

            try
            {
                using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(sqlConstr))
                {
                    using (System.Data.SqlClient.SqlCommand StoreProc = new System.Data.SqlClient.SqlCommand("UpdateClienteFornitore"))
                    {
                        using (System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter())
                        {
                            StoreProc.Connection  = con;
                            sda.SelectCommand     = StoreProc;
                            StoreProc.CommandType = CommandType.StoredProcedure;

                            System.Data.SqlClient.SqlParameter id = new System.Data.SqlClient.SqlParameter("@id", azienda.Id);
                            id.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(id);

                            // PARAMETRI PER LOG UTENTE
                            SqlParameter idUtente = new SqlParameter("@idUtente", utente.id);
                            idUtente.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(idUtente);

                            SqlParameter nomeUtente = new SqlParameter("@nomeUtente", utente.username);
                            nomeUtente.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(nomeUtente);
                            // FINE PARAMETRI PER LOG UTENTE

                            SqlParameter attivo = new SqlParameter("@attivo", azienda.Attivo);
                            attivo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(attivo);

                            SqlParameter capLegale = new SqlParameter("@capLegale", azienda.CapLegale);
                            capLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(capLegale);

                            SqlParameter capOperativo = new SqlParameter("@capOperativo", azienda.CapOperativo);
                            capOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(capOperativo);

                            SqlParameter cliente = new SqlParameter("@cliente", azienda.Cliente);
                            cliente.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(cliente);

                            SqlParameter codiceFiscale = new SqlParameter("@codiceFiscale", azienda.CodiceFiscale);
                            codiceFiscale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(codiceFiscale);

                            SqlParameter codiceIdentificativo = new SqlParameter("@codiceIdentificativo", azienda.CodiceIdentificativo);
                            codiceIdentificativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(codiceIdentificativo);

                            SqlParameter comuneLegale = new SqlParameter("@comuneLegale", azienda.ComuneLegale);
                            comuneLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(comuneLegale);

                            SqlParameter comuneOperativo = new SqlParameter("@comuneOperativo", azienda.ComuneOperativo);
                            comuneOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(comuneOperativo);

                            SqlParameter email = new SqlParameter("@email", azienda.Email);
                            email.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(email);

                            SqlParameter fax = new SqlParameter("@fax", azienda.Fax);
                            fax.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(fax);

                            SqlParameter fornitore = new SqlParameter("@fornitore", azienda.Fornitore);
                            fornitore.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(fornitore);

                            SqlParameter iban = new SqlParameter("@iban", azienda.Iban);
                            iban.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(iban);

                            SqlParameter indirizzoLegale = new SqlParameter("@indirizzoLegale", azienda.IndirizzoLegale);
                            indirizzoLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(indirizzoLegale);

                            SqlParameter indirizzoOperativo = new SqlParameter("@indirizzoOperativo", azienda.IndirizzoOperativo);
                            indirizzoOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(indirizzoOperativo);

                            SqlParameter nazioneLegale = new SqlParameter("@nazioneLegale", azienda.NazioneLegale);
                            nazioneLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(nazioneLegale);

                            SqlParameter nazioneOperativo = new SqlParameter("@nazioneOperativo", azienda.NazioneOperativo);
                            nazioneOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(nazioneOperativo);

                            SqlParameter note = new SqlParameter("@note", azienda.Note);
                            note.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(note);

                            SqlParameter numeroCivicoLegale = new SqlParameter("@numeroCivicoLegale", azienda.NumeroCivicoLegale);
                            numeroCivicoLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(numeroCivicoLegale);

                            SqlParameter numeroCivicoOperativo = new SqlParameter("@numeroCivicoOperativo", azienda.NumeroCivicoOperativo);
                            numeroCivicoOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(numeroCivicoOperativo);

                            SqlParameter pagamento = new SqlParameter("@pagamento", azienda.Pagamento);
                            pagamento.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(pagamento);

                            SqlParameter partitaIva = new SqlParameter("@partitaIva", azienda.PartitaIva);
                            partitaIva.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(partitaIva);

                            SqlParameter pec = new SqlParameter("@pec", azienda.Pec);
                            pec.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(pec);

                            SqlParameter provinciaLegale = new SqlParameter("@provinciaLegale", azienda.ProvinciaLegale);
                            provinciaLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(provinciaLegale);

                            SqlParameter provinciaOperativo = new SqlParameter("@provinciaOperativo", azienda.ProvinciaOperativo);
                            provinciaOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(provinciaOperativo);

                            SqlParameter ragioneSociale = new SqlParameter("@ragioneSociale", azienda.RagioneSociale);
                            ragioneSociale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(ragioneSociale);

                            SqlParameter telefono = new SqlParameter("@telefono", azienda.Telefono);
                            telefono.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(telefono);

                            SqlParameter tipo = new SqlParameter("@tipo", azienda.Tipo);
                            tipo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(tipo);

                            SqlParameter tipoIndirizzoLegale = new SqlParameter("@tipoIndirizzoLegale", azienda.TipoIndirizzoLegale);
                            tipoIndirizzoLegale.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(tipoIndirizzoLegale);

                            SqlParameter tipoIndirizzoOperativo = new SqlParameter("@tipoIndirizzoOperativo", azienda.TipoIndirizzoOperativo);
                            tipoIndirizzoOperativo.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(tipoIndirizzoOperativo);

                            SqlParameter webSite = new SqlParameter("@webSite", azienda.WebSite);
                            webSite.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(webSite);

                            SqlParameter notaPagamento = new SqlParameter("@notaPagamento", azienda.NotaPagamento);
                            notaPagamento.Direction = ParameterDirection.Input;
                            StoreProc.Parameters.Add(notaPagamento);

                            StoreProc.Connection.Open();

                            int iReturn = StoreProc.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_SCRITTURA_TABELLA;
                esito.Descrizione = "Anag_Clienti_Fornitori_DAL.cs - aggiornaAzienda " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace;
            }

            return(esito);
        }
コード例 #10
0
        public List <Anag_Clienti_Fornitori> CaricaListaAziende(ref Esito esito, bool soloAttivi = true)
        {
            List <Anag_Clienti_Fornitori> listaAziende = new List <Anag_Clienti_Fornitori>();

            try
            {
                using (SqlConnection con = new SqlConnection(sqlConstr))
                {
                    string query = "SELECT * FROM anag_clienti_fornitori";
                    if (soloAttivi)
                    {
                        query += " WHERE ATTIVO = 1";
                    }
                    query += " ORDER BY ragioneSociale";
                    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)
                                    {
                                        Anag_Clienti_Fornitori azienda = new Anag_Clienti_Fornitori
                                        {
                                            Id                     = riga.Field <int>("id"),
                                            Attivo                 = riga.Field <bool>("attivo"),
                                            CapLegale              = riga.Field <string>("capLegale"),
                                            CapOperativo           = riga.Field <string>("capOperativo"),
                                            Cliente                = riga.Field <bool>("cliente"),
                                            CodiceFiscale          = riga.Field <string>("codiceFiscale"),
                                            CodiceIdentificativo   = riga.Field <string>("codiceIdentificativo"),
                                            ComuneLegale           = riga.Field <string>("comuneLegale"),
                                            ComuneOperativo        = riga.Field <string>("comuneOperativo"),
                                            Email                  = riga.Field <string>("email"),
                                            Telefono               = riga.Field <string>("telefono"),
                                            Fax                    = riga.Field <string>("fax"),
                                            Fornitore              = riga.Field <bool>("fornitore"),
                                            Iban                   = riga.Field <string>("iban"),
                                            TipoIndirizzoLegale    = riga.Field <string>("tipoIndirizzoLegale"),
                                            IndirizzoLegale        = riga.Field <string>("indirizzoLegale"),
                                            TipoIndirizzoOperativo = riga.Field <string>("tipoIndirizzoOperativo"),
                                            IndirizzoOperativo     = riga.Field <string>("indirizzoOperativo"),
                                            NazioneLegale          = riga.Field <string>("nazioneLegale"),
                                            NazioneOperativo       = riga.Field <string>("nazioneOperativo"),
                                            Note                   = riga.Field <string>("note"),
                                            NumeroCivicoLegale     = riga.Field <string>("numeroCivicoLegale"),
                                            NumeroCivicoOperativo  = riga.Field <string>("numeroCivicoOperativo"),
                                            Pagamento              = riga.Field <int>("pagamento"),
                                            PartitaIva             = riga.Field <string>("partitaIva"),
                                            Pec                    = riga.Field <string>("pec"),
                                            ProvinciaLegale        = riga.Field <string>("provinciaLegale"),
                                            ProvinciaOperativo     = riga.Field <string>("provinciaOperativo"),
                                            RagioneSociale         = riga.Field <string>("ragioneSociale"),
                                            WebSite                = riga.Field <string>("webSite"),
                                            NotaPagamento          = riga.Field <string>("notaPagamento")
                                        };

                                        azienda.Referenti = Anag_Referente_Clienti_Fornitori_DAL.Instance.getReferentiByIdAzienda(ref esito, azienda.Id);

                                        listaAziende.Add(azienda);
                                    }
                                }
                                else
                                {
                                    esito.Codice      = Esito.ESITO_KO_ERRORE_NO_RISULTATI;
                                    esito.Descrizione = "Nessun dato trovato nella tabella anag_clienti_fornitori ";
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = ex.Message + Environment.NewLine + ex.StackTrace;
            }

            return(listaAziende);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public Esito AggiornaAzienda(Anag_Clienti_Fornitori azienda, Anag_Utenti utente)
 {
     return(Anag_Clienti_Fornitori_DAL.Instance.AggiornaAzienda(azienda, utente));
 }
コード例 #15
0
 public int CreaAzienda(Anag_Clienti_Fornitori azienda, Anag_Utenti utente, ref Esito esito)
 {
     return(Anag_Clienti_Fornitori_DAL.Instance.CreaAzienda(azienda, utente, ref esito));
 }