Example #1
0
        //Stampa PDF

        public void ExportToPdfPerContoFinCli(List <MaterialiCantieri> matCantList)
        {
            decimal           totale     = 0m;
            int               idCantiere = Convert.ToInt32(ddlScegliCant.SelectedValue);
            Cantieri          cant       = CantieriDAO.GetSingle(idCantiere);
            MaterialiCantieri mc         = new MaterialiCantieri
            {
                RagSocCli     = cant.RagSocCli,
                CodCant       = cant.CodCant,
                DescriCodCant = cant.DescriCodCant
            };

            //Apro lo stream verso il file PDF
            Document pdfDoc = new Document(PageSize.A4, 8f, 2f, 2f, 2f);

            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();

            PdfPTable table = RicalcoloContiManager.InitializePdfTableDDT();

            Phrase title = new Phrase($"Ragione Sociale Cliente: {mc.RagSocCli}", FontFactory.GetFont("Arial", 16, iTextSharp.text.Font.BOLD, BaseColor.BLACK));

            pdfDoc.Add(title);

            RicalcoloContiManager.GeneraPDFPerContoFinCli(pdfDoc, mc, table, matCantList, totale, idCantiere, ddlScegliTipoNote.SelectedValue);

            pdfDoc.Close();
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=" + mc.RagSocCli + ".pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Write(pdfDoc);
            Response.End();
        }
        protected void btnStampaContoCliente_Click(object sender, EventArgs e)
        {
            //Ricreo i passaggi della "Stampa Ricalcolo Conti" per ottenere il valore del "Totale Ricalcolo"
            int               idCantiere = Convert.ToInt32(ddlScegliCant.SelectedItem.Value);
            Cantieri          cant       = CantieriDAO.GetSingle(idCantiere);
            MaterialiCantieri mc         = new MaterialiCantieri
            {
                RagSocCli     = cant.RagSocCli,
                CodCant       = cant.CodCant,
                DescriCodCant = cant.DescriCodCant
            };

            PdfPTable pTable = RicalcoloContiManager.InitializePdfTableDDT();
            Document  pdfDoc = new Document(PageSize.A4, 8f, 2f, 2f, 2f);

            pdfDoc.Open();
            List <MaterialiCantieri> materiali = RicalcoloContiManager.GetMaterialiCantieri(idCantiere);

            RicalcoloContiManager.GeneraPDFPerContoFinCli(pdfDoc, mc, pTable, materiali, 0, idCantiere);
            pdfDoc.Close();

            //Popolo i campi di riepilogo con i dati necessari
            CompilaCampi(idCantiere, materiali.Sum(s => s.Valore));
        }