public iText.Layout.Element.Table getTable(PdfDocumentEvent docEvent)
        {
            float[] cellWidth = { 20f, 80f };
            iText.Layout.Element.Table tableEvent = new iText.Layout.Element.Table(UnitValue.CreatePercentArray(cellWidth)).UseAllAvailableWidth();

            iText.Layout.Style styleCell = new iText.Layout.Style()
                                           .SetBorder(Border.NO_BORDER);

            iText.Layout.Style styleText = new iText.Layout.Style()
                                           .SetTextAlignment(TextAlignment.RIGHT).SetFontSize(10f);

            Cell cell = new Cell().Add(Img.SetAutoScale(true));

            tableEvent.AddCell(cell
                               .AddStyle(styleCell)
                               .SetTextAlignment(TextAlignment.LEFT));
            PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.TIMES_BOLD);

            cell = new Cell()
                   .Add(new Paragraph("CareMonitor")).SetFont(bold)
                   .Add(new Paragraph("Fecha de Emisión: " + DateTime.Now.ToShortDateString()))
                   .AddStyle(styleText).AddStyle(styleCell);

            tableEvent.AddCell(cell);
            return(tableEvent);
        }
示例#2
0
        /// <summary>
        /// Make table of given contacts collection and writes it into PDF file. Writes only header if the collection is empty
        /// </summary>
        /// <param name="document"></param>
        /// <param name="contacts"></param>
        private static void processContactsToBandExport(Document document, ArrayList contacts)
        {
            PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);
            PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            //set number of table columns and their width relative to each other (that works weird, changing values has no affection)
            Table table = new Table(new float[] { 1, 1, 1, 1 });

            //table width related to page
            table.SetWidth(UnitValue.CreatePercentValue(100));

            //process header
            string headerLine = "Jméno, Funkce, Telefon, Email";

            process(table, headerLine, bold, true);

            if (contacts.Count != 0)
            {
                foreach (BandContact contact in contacts)
                {
                    string line;
                    string phone;
                    string email;

                    if (Regex.IsMatch(contact.phone, @"^(\d{9}|\+\d{12})$"))

                    {
                        phone = contact.phone;
                    }
                    else
                    {
                        phone = "NIL";
                    }

                    if (contact.email.Count() > 3)
                    {
                        email = contact.email;
                    }
                    else
                    {
                        email = "NIL";
                    }

                    line = string.Format("{0}, {1}, {2}, {3}", contact.fName + contact.lName, contact.function, phone, email);

                    //process data rows into table
                    process(table, line, font, false);
                }
            }
            document.Add(table);
        }
示例#3
0
        /// <summary>
        /// Process table row for PDF export
        /// </summary>
        /// <param name="table"></param>
        /// <param name="line"></param>
        /// <param name="font"></param>
        /// <param name="isHeader"></param>
        private static void process(Table table, String line, PdfFont font, Boolean isHeader)
        {
            StringTokenizer tokenizer = new StringTokenizer(line, ",");

            while (tokenizer.HasMoreTokens())
            {
                if (isHeader)
                {
                    table.AddHeaderCell(new Cell().SetBackgroundColor(WebColors.GetRGBColor("A6B8AE")).Add(new Paragraph(tokenizer.NextToken()).SetFont(font)));
                }
                else
                {
                    table.AddCell(new Cell().Add(new iText.Layout.Element.Paragraph(tokenizer.NextToken()).SetFont(font)));
                }
            }
        }
示例#4
0
        private void add_iva_subtotal(Document document, iText.Layout.Element.Table table)
        {
            Process(table, "", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "SUBTOTAL", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "$" + subtotal, PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);


            Process(table, "", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "IVA", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "$" + iva, PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);


            Process(table, "", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "TOTAL", PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);
            Process(table, "$" + cantidad, PdfFontFactory.CreateFont(StandardFonts.HELVETICA), false);

            document.Add(table);
        }
        protected void btnGenerarReporte_Click(object sender, EventArgs e)
        {
            MemoryStream ms = new MemoryStream();

            PdfWriter   pw  = new PdfWriter(ms);
            PdfDocument pdf = new PdfDocument(pw);
            Document    doc = new Document(pdf, PageSize.A4);

            doc.SetMargins(75, 35, 70, 35);
            string pathLogo = Server.MapPath("../Imagenes/Care Monitor.jpg");

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(iText.IO.Image.ImageDataFactory.Create(pathLogo));

            pdf.AddEventHandler(PdfDocumentEvent.START_PAGE, new HeaderEventHandler(img));


            iText.Layout.Element.Table tabla = new iText.Layout.Element.Table(1).UseAllAvailableWidth();
            Cell cell = new Cell().Add(new Paragraph("Reporte de Bitácora").SetFontSize(14)
                                       .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                                       .SetBorder(Border.NO_BORDER));

            tabla.AddCell(cell);

            doc.Add(tabla);

            iText.Layout.Style styleCell = new iText.Layout.Style()
                                           .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                                           .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);

            iText.Layout.Element.Table _tabla = new iText.Layout.Element.Table(4).UseAllAvailableWidth();
            Cell _cell = new Cell().Add(new Paragraph("Fecha"));

            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Usuario"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Tipo"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Acción"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));



            List <BE.Bitacora> listaBitacora = (List <BE.Bitacora>)Session["ListaBitacora"];

            foreach (BE.Bitacora bit in listaBitacora)
            {
                _cell = new Cell().Add(new Paragraph(bit.Fecha.ToString("g")));
                _tabla.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(bit.Usuario));
                _tabla.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(bit.Tipo));
                _tabla.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(bit.Accion));
                _tabla.AddCell(_cell);
            }

            doc.Add(_tabla);

            doc.Close();

            byte[] bytesStream = ms.ToArray();
            ms = new MemoryStream();
            ms.Write(bytesStream, 0, bytesStream.Length);
            ms.Position = 0;

            Response.AddHeader("content-disposition", "inline;filename=Reporte.pdf");
            Response.ContentType = "application/octectstream";
            Response.BinaryWrite(bytesStream);
            Response.End();
        }
示例#6
0
        public string crear_pdf(Entities.Model.Order order, List <CartItem> carrito, Shipping ship)
        {
            MemoryStream ms          = new MemoryStream();
            PdfWriter    pw          = new PdfWriter(ms);
            PdfDocument  pdfdocument = new PdfDocument(pw);
            Document     doc         = new Document(pdfdocument, PageSize.A4);

            doc.SetMargins(75, 35, 70, 35);

            //PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            string pathlogo = Server.MapPath("~/Content/assets/img/core-img/logo.png");

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create(pathlogo));

            //Cabecera
            iText.Layout.Element.Cell  separador = new iText.Layout.Element.Cell(1, 1);
            iText.Layout.Element.Table table     = new iText.Layout.Element.Table(2).UseAllAvailableWidth() /*.SetBorder(Border.NO_BORDER)*/;
            iText.Layout.Element.Cell  cell      = new iText.Layout.Element.Cell(4, 1).SetTextAlignment(TextAlignment.LEFT).SetBorder(Border.NO_BORDER);
            cell.Add(img.ScaleToFit(150, 150));
            table.AddCell(cell);
            cell = new iText.Layout.Element.Cell(2, 2).Add(new Paragraph("Factura No: 0177-" + string.Format("{0:00000000}", order.Id)))
                   .SetTextAlignment(TextAlignment.RIGHT)
                   .SetBorder(Border.NO_BORDER);
            table.AddCell(cell);
            cell = new iText.Layout.Element.Cell(2, 2).Add(new Paragraph("Fecha: " + DateTime.Today.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture)))
                   .SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER);
            table.AddCell(cell);

            doc.Add(table);


            //Datos Cliente
            iText.Layout.Element.Table _clienttable = new iText.Layout.Element.Table(1).UseAllAvailableWidth().SetMarginTop(20) /*.SetBorder(Border.NO_BORDER)*/;
            _clienttable.AddCell(separador);
            iText.Layout.Element.Cell _clientecell = new iText.Layout.Element.Cell(1, 1);
            _clientecell.Add(new Paragraph("Nombre: " + ship.FirstName + " " + ship.LastName))
            .SetTextAlignment(TextAlignment.LEFT)
            .SetMarginBottom(10).SetBorder(Border.NO_BORDER);
            _clienttable.AddCell(_clientecell);
            _clientecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Dirección: " + ship.Address))
                           .SetTextAlignment(TextAlignment.LEFT).SetMarginBottom(10).SetBorder(Border.NO_BORDER);

            _clienttable.AddCell(_clientecell);
            _clientecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Ciudad: " + ship.City))
                           .SetTextAlignment(TextAlignment.LEFT).SetMarginBottom(10).SetBorder(Border.NO_BORDER);
            _clienttable.AddCell(_clientecell);
            _clientecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("País: " + ship.Country))
                           .SetTextAlignment(TextAlignment.LEFT).SetMarginBottom(10).SetBorder(Border.NO_BORDER);
            _clienttable.AddCell(_clientecell);
            _clientecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Email: " + ship.Email))
                           .SetTextAlignment(TextAlignment.LEFT).SetMarginBottom(10).SetBorder(Border.NO_BORDER);
            _clienttable.AddCell(_clientecell);
            _clienttable.AddCell(separador);
            doc.Add(_clienttable);


            //doc.Add(ls);
            //Datos Product Encabezado
            iText.Layout.Element.Table _prodtable = new iText.Layout.Element.Table(6).UseAllAvailableWidth().SetMarginTop(20) /*.SetBorder(Border.NO_BORDER)*/;

            iText.Layout.Element.Cell _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("# Item"))
                                                   .SetTextAlignment(TextAlignment.CENTER)
                                                   .SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);
            _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Codigo Articulo"))
                         .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);
            _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Descripcion"))
                         .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);
            _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Precio Unitario"))
                         .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);
            _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Cantidad"))
                         .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);
            _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Subtotal"))
                         .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
            _prodtable.AddCell(_prodecell);

            int x = 0;

            foreach (CartItem item in carrito)
            {
                x++;
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph(x.ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph(item.ProductId.ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph(item.Product.Title.ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph(item.Price.ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph(item.Quantity.ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
                _prodecell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph((item.Quantity * item.Price).ToString())).SetBorder(Border.NO_BORDER)
                             .SetTextAlignment(TextAlignment.CENTER).SetMarginBottom(10);
                _prodtable.AddCell(_prodecell);
            }
            doc.Add(_prodtable);

            //Total
            iText.Layout.Element.Table totaltable = new iText.Layout.Element.Table(1).UseAllAvailableWidth().SetMarginTop(20) /*.SetBorder(Border.NO_BORDER)*/;

            iText.Layout.Element.Cell totalcell = new iText.Layout.Element.Cell(1, 1).Add(new Paragraph("Total: $" + order.TotalPrice))
                                                  .SetTextAlignment(TextAlignment.RIGHT)
                                                  .SetMarginBottom(10).SetBorder(Border.NO_BORDER);
            totaltable.AddCell(totalcell);
            doc.Add(totaltable);
            //pdfdocument.AddEventHandler(PdfDocumentEvent.END_PAGE, new HeaderEventHandler1(img));

            //iText.Layout.Element.Table _table = new iText.Layout.Element.Table(1).UseAllAvailableWidth();

            doc.Close();

            byte[] byteStream    = ms.ToArray();
            var    inputAsString = Convert.ToString(Convert.ToBase64String(ms.ToArray()));

            ms = new MemoryStream();
            ms.Write(byteStream, 0, byteStream.Length);
            ms.Position = 0;
            var pdf = new FileStreamResult(ms, "application/pdf");

            /*return new FileStreamResult(ms, "application/pdf")*/;

            return(inputAsString.ToString());
        }
示例#7
0
        private Table CreateHeaders(Document document, Style headerStyle, string title)
        {
            Bitmap         bmpImage  = Properties.Resources.SICE;
            ImageConverter converter = new ImageConverter();

            Byte[]    byteImage = (byte[])converter.ConvertTo(bmpImage, typeof(byte[]));
            ImageData imageData = ImageDataFactory.Create(byteImage);

            iText.Layout.Element.Image pdfImg = new iText.Layout.Element.Image(imageData);
            pdfImg.SetHeight(150);
            pdfImg.SetWidth(200);
            pdfImg.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);
            document.Add(pdfImg);


            PdfFont font = PdfFontFactory.CreateFont(FontConstants.TIMES_BOLD);

            Style titleStyle = new Style();

            titleStyle.SetFont(font).SetFontSize(24);
            titleStyle.SetBold();
            document.Add(new Paragraph(title).AddStyle(titleStyle));


            Table table = new Table(37);

            table.AddHeaderCell("Document");
            table.AddHeaderCell("I 1").AddStyle(headerStyle);
            table.AddHeaderCell("I 3").AddStyle(headerStyle);
            table.AddHeaderCell("I 2").AddStyle(headerStyle);
            table.AddHeaderCell("I 4").AddStyle(headerStyle);
            table.AddHeaderCell("I 5").AddStyle(headerStyle);
            table.AddHeaderCell("I 6").AddStyle(headerStyle);
            table.AddHeaderCell("I 7").AddStyle(headerStyle);
            table.AddHeaderCell("I 8").AddStyle(headerStyle);
            table.AddHeaderCell("I 9").AddStyle(headerStyle);
            table.AddHeaderCell("I 10").AddStyle(headerStyle);
            table.AddHeaderCell("I 11").AddStyle(headerStyle);
            table.AddHeaderCell("I 12").AddStyle(headerStyle);
            table.AddHeaderCell("I 13").AddStyle(headerStyle);
            table.AddHeaderCell("I 14").AddStyle(headerStyle);
            table.AddHeaderCell("I 15").AddStyle(headerStyle);
            table.AddHeaderCell("I 16").AddStyle(headerStyle);
            table.AddHeaderCell("I 17").AddStyle(headerStyle);
            table.AddHeaderCell("Database").AddStyle(headerStyle);
            table.AddHeaderCell("I 1").AddStyle(headerStyle);
            table.AddHeaderCell("I 3").AddStyle(headerStyle);
            table.AddHeaderCell("I 2").AddStyle(headerStyle);
            table.AddHeaderCell("I 4").AddStyle(headerStyle);
            table.AddHeaderCell("I 5").AddStyle(headerStyle);
            table.AddHeaderCell("I 6").AddStyle(headerStyle);
            table.AddHeaderCell("I 7").AddStyle(headerStyle);
            table.AddHeaderCell("I 8").AddStyle(headerStyle);
            table.AddHeaderCell("I 9").AddStyle(headerStyle);
            table.AddHeaderCell("I 10").AddStyle(headerStyle);
            table.AddHeaderCell("I 11").AddStyle(headerStyle);
            table.AddHeaderCell("I 12").AddStyle(headerStyle);
            table.AddHeaderCell("I 13").AddStyle(headerStyle);
            table.AddHeaderCell("I 14").AddStyle(headerStyle);
            table.AddHeaderCell("I 15").AddStyle(headerStyle);
            table.AddHeaderCell("I 16").AddStyle(headerStyle);
            table.AddHeaderCell("I 17").AddStyle(headerStyle);
            table.AddHeaderCell("Result").AddStyle(headerStyle);
            return(table);
        }
示例#8
0
        private void ExportComparison(object title)
        {
            // Must have write permissions to the path folder
            FileInfo file = new FileInfo(titlePDF.ToString() + ".pdf");

            file.Delete();
            var fileStream = file.Create();

            fileStream.Close();
            PdfDocument pdfdoc      = new PdfDocument(new PdfWriter(file));
            PdfFont     font        = PdfFontFactory.CreateFont(StandardFonts.TIMES_BOLD);
            PdfFont     cellFont    = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN);
            PdfFont     OKFont      = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN);
            PdfFont     NOKFont     = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN);
            Style       headerStyle = new Style();

            headerStyle.SetFont(font).SetFontSize(11);
            headerStyle.SetBold();
            Style cellStyle = new Style();

            cellStyle.SetFont(cellFont).SetFontSize(10);
            Style OKStyle = new Style();

            OKStyle.SetFont(OKFont).SetFontSize(10);
            OKStyle.SetFontColor(ColorConstants.GREEN, 1);
            Style NOKStyle = new Style();

            NOKStyle.SetFont(NOKFont).SetFontSize(10);
            NOKStyle.SetFontColor(ColorConstants.RED, 1);

            pdfdoc.SetDefaultPageSize(PageSize.A2.Rotate());
            pdfdoc.SetTagged();
            using (Document document = new Document(pdfdoc))
            {
                iText.Layout.Element.Cell cell;
                Table table = CreateHeaders(document, headerStyle, title.ToString());
                for (int i = 0; i < documentationImportList.Count; i++)
                {
                    cell = new iText.Layout.Element.Cell(1, 1);
                    cell.Add(new Paragraph(documentationImportList[i].deviceName)).AddStyle(cellStyle);
                    table.AddCell(cell);
                    foreach (string iconName in documentationImportList[i].iconNames)
                    {
                        // documentationImportList[i].iconNames;
                        if (File.Exists(imagesDir + "icono" + iconName + ".png"))
                        {
                            ImageData imageData = ImageDataFactory.Create(imagesDir + "icono" + iconName + ".png");
                            iText.Layout.Element.Image pdfImg = new iText.Layout.Element.Image(imageData);
                            pdfImg.SetHeight(32);
                            pdfImg.SetWidth(32);
                            table.AddCell(pdfImg);
                        }
                        else
                        {
                            table.AddCell("X");
                        }
                    }

                    for (int j = documentationImportList[i].iconNames.Count; j < 17; j++)
                    {
                        table.AddCell("");
                    }

                    DeviceIconGroup databaseItem = databaseImportList.Find(x => x.deviceName.Equals(documentationImportList[i].deviceName));
                    cell = new iText.Layout.Element.Cell(1, 1);
                    cell.Add(new Paragraph(databaseItem.deviceName)).AddStyle(cellStyle);
                    table.AddCell(cell);//.AddStyle(cellStyle);


                    foreach (string iconName in databaseItem.iconNames)
                    {
                        if (File.Exists(imagesDir + "icono" + iconName + ".png"))
                        {
                            // documentationImportList[i].iconNames;
                            ImageData imageData = ImageDataFactory.Create(imagesDir + "icono" + iconName + ".png");
                            iText.Layout.Element.Image pdfImg = new iText.Layout.Element.Image(imageData);
                            pdfImg.SetHeight(32);
                            pdfImg.SetWidth(32);
                            table.AddCell(pdfImg);
                        }
                        else
                        {
                            table.AddCell("X");
                        }
                    }


                    for (int j = 19 + databaseItem.iconNames.Count; j < 36; j++)
                    {
                        table.AddCell("");
                    }

                    if (documentationImportList[i].IsEqualTo(databaseItem))
                    {
                        cell = new iText.Layout.Element.Cell(1, 1);
                        cell.Add(new Paragraph("OK")).AddStyle(OKStyle);
                        table.AddCell(cell);
                    }
                    else
                    {
                        cell = new iText.Layout.Element.Cell(1, 1);
                        cell.Add(new Paragraph("NOK")).AddStyle(NOKStyle);
                        table.AddCell(cell);
                    }

                    this.Dispatcher.Invoke(
                        new UpdatePgBar(this.updatePgBar),
                        new object[] { (double.Parse(i.ToString()) / double.Parse(documentationImportList.Count().ToString())) * 100 }
                        );
                }

                //Create table
                document.Add(table);


                this.Dispatcher.Invoke(
                    new FinishReading(EnableWindowOptions),
                    new object[] { }
                    );
            }
        }
示例#9
0
        public bool CreateVMDasaChart(ref iText.Layout.Document pdfDocObj, DateTime dtDasaStartDate, string strDasaLord, ref string errorMessage)
        {
            try
            {
                CalculateVMDasa(dtDasaStartDate, strDasaLord);

                float   PdfDefaultFontSize = 10.0f;
                float[] columnHouses       = { 4f, 4f, 4f, 4f, 4f, 4f };

                iText.Layout.Element.Table vmDasaTable = new iText.Layout.Element.Table(UnitValue.CreatePercentArray(columnHouses)).UseAllAvailableWidth();

                int  nLineNumber = 0;
                bool bPrintTitle = true;
                for (int nDasaEntry = 1; nDasaEntry <= DasaList.Count; nDasaEntry++)
                {
                    if (nDasaEntry >= 729)
                    {
                        break;
                    }

                    if (bPrintTitle == true)
                    {
                        if (((vmDasaElement)DasaList[nDasaEntry]).DasaBeginning == true)
                        {
                            int      nDasaPlanetIndex = GetDasaPlanetIndex(((vmDasaElement)DasaList[nDasaEntry]).DasaLord);
                            DateTime dtVMDasaEndDate  = ((vmDasaElement)DasaList[nDasaEntry]).dtStartDate;
                            dtVMDasaEndDate = dtVMDasaEndDate.AddYears(DasaYears[nDasaPlanetIndex]);
                            string strVMDasaTitle = string.Format("{0} Dasa from {1} to {2} (Anthara Ending Dates)", GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry]).DasaLord), ((vmDasaElement)DasaList[nDasaEntry]).dtStartDate.ToString("dd-MM-yyyy"), dtVMDasaEndDate.ToString("dd-MM-yyyy"));
                            vmDasaTable.AddCell(new Cell(1, 6).SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(strVMDasaTitle).SetFont(PdfFontBoldObj).SetFontSize(PdfDefaultFontSize)).SetBackgroundColor(new DeviceRgb(180, 230, 99)));
                        }

                        vmDasaTable.AddCell(new Cell(1, 2).SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry]).BukthiLord) + " Bukthi").SetFont(PdfFontBoldObj).SetFontSize(PdfDefaultFontSize)));
                        vmDasaTable.AddCell(new Cell(1, 2).SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry + 9]).BukthiLord) + " Bukthi").SetFont(PdfFontBoldObj).SetFontSize(PdfDefaultFontSize)));
                        vmDasaTable.AddCell(new Cell(1, 2).SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry + 18]).BukthiLord) + " Bukthi").SetFont(PdfFontBoldObj).SetFontSize(PdfDefaultFontSize)));
                        nLineNumber++;
                        bPrintTitle = false;
                    }

                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry]).AntharaLord)).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));
                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(((vmDasaElement)DasaList[nDasaEntry]).EndDate).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));

                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry + 9]).AntharaLord)).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));
                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(((vmDasaElement)DasaList[nDasaEntry + 9]).EndDate).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));

                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(GetDasaPlanetName(((vmDasaElement)DasaList[nDasaEntry + 18]).AntharaLord)).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));
                    vmDasaTable.AddCell(new Cell().SetHeight(20).SetTextAlignment(TextAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE).Add(new Paragraph(((vmDasaElement)DasaList[nDasaEntry + 18]).EndDate).SetFont(PdfFontObj).SetFontSize(PdfDefaultFontSize)));
                    nLineNumber++;

                    if ((nDasaEntry + 18) % 27 == 0)
                    {
                        nDasaEntry  = nDasaEntry + 18;
                        bPrintTitle = true;
                    }
                }

                pdfDocObj.Add(vmDasaTable);

                return(true);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            return(false);
        }
示例#10
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);
        }
示例#11
0
        private void btnReporteValoracion_Click(object sender, RoutedEventArgs e)
        {
            if (!validarFechas())
            {
                MessageBox.Show("La fecha de inicio debe ser menor a la de termino\n Ingrese nuevamente", "Reporteria - Mis Ofertas");
                dpFechaInicio.Focus();
            }
            else
            {
                try
                {
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    List <ReporteValoracion> listaRegistros = new List <ReporteValoracion>();

                    if (dpFechaInicio.SelectedDate == null && dpFechaTermino.SelectedDate == null)
                    {
                        listaRegistros = reporteValoracionNeg.listaRegistrosReporteValoracion(null, null);
                    }
                    else
                    {
                        listaRegistros = reporteValoracionNeg.listaRegistrosReporteValoracion(
                            dpFechaInicio.SelectedDate,
                            dpFechaTermino.SelectedDate);
                    }


                    String rutaDirectorioOferta             = "D:/MisOfertas/Reportes/";
                    List <ImagenOferta> listaImagenesOferta = new List <ImagenOferta>();
                    if (!Directory.Exists(rutaDirectorioOferta))
                    {
                        Directory.CreateDirectory(rutaDirectorioOferta);
                    }

                    DateTime fechaCreacionReporte = DateTime.Now;
                    String   rutaReporte          = rutaDirectorioOferta + "/ReporteValoracion" + fechaCreacionReporte.ToString("ddMMyyyyHHmm") + ".pdf";

                    PdfWriter   writer   = new PdfWriter(rutaReporte);
                    PdfDocument pdf      = new PdfDocument(writer);
                    Document    document = new Document(pdf, PageSize.A4);
                    PdfFont     font     = PdfFontFactory.CreateFont(FontConstants.TIMES_ROMAN);


                    string _filePath = System.IO.Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
                    _filePath  = Directory.GetParent(_filePath).FullName;
                    _filePath  = Directory.GetParent(_filePath).FullName;
                    _filePath += @"\img\MisOfertas-Letras.png";

                    //string ruta_imagen = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"img\MisOfertas-Letras.png");
                    //String ruta_imagen = "D:/Portafolio 2017/MisOfertasEscritorio/Seba/Satelite_MisOfertas/View/img/MisOfertas-Letras.png";
                    document.Add(new iText.Layout.Element.Image(ImageDataFactory.Create(_filePath)).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.RIGHT).SetWidth(40).SetHeight(40));


                    document.Add(new iText.Layout.Element.Paragraph("Reporte valoracion de ofertas").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));
                    document.Add(new iText.Layout.Element.Paragraph(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()).SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(18));

                    float[] columnWidths = { 1, 5, 6, 5, 5, 5, 5, 5, 5, 5 };//{1,1,10,10,5,5,1,1,1,1,1,1};

                    iText.Layout.Element.Table tableRegistros = new iText.Layout.Element.Table(10).SetFontSize(12);
                    tableRegistros.SetWidthPercent(100);
                    tableRegistros.SetFixedLayout();

                    float fontCell     = 11;
                    float fontCellData = 9;

                    Cell[] headerFooter = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Oferta").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Inicio").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Finalizacion").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Rubro").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Empresa").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Val. Negativas").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Val. Medias").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Val. Positivas").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Total").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                    };
                    //new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Productos").SetFontSize(fontCell),
                    //new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Imagenes").SetFontSize(fontCell)};


                    foreach (Cell hfCell in headerFooter)
                    {
                        tableRegistros.AddHeaderCell(hfCell);
                    }

                    for (int i = 0; i < listaRegistros.Count; i++)
                    {
                        ReporteValoracion reporte = listaRegistros[i];
                        Oferta            oferta  = reporte.Oferta;
                        Rubro             rubro   = reporte.Rubro;
                        Empresa           empresa = reporte.Empresa;
                        tableRegistros.AddCell(oferta.IdOferta.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableRegistros.AddCell(oferta.TituloOferta).SetFontSize(fontCellData);
                        tableRegistros.AddCell(oferta.FechaInicio.ToShortDateString()).SetFontSize(fontCellData);
                        tableRegistros.AddCell(oferta.FechaFinalizacion.ToShortDateString()).SetFontSize(fontCellData);
                        tableRegistros.AddCell(rubro.DescripcionRubro).SetFontSize(fontCellData);
                        tableRegistros.AddCell(empresa.NombreEmpresa).SetFontSize(fontCellData);
                        tableRegistros.AddCell(reporte.CantValoracionNegativas.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableRegistros.AddCell(reporte.CantValoracionMedia.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableRegistros.AddCell(reporte.CantValoracionPositiva.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableRegistros.AddCell(reporte.CantValoracionTotal.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    //tableRegistros.AddCell(reporte.CantProductos.ToString()).SetFontSize(fontCellData);
                    //tableRegistros.AddCell(reporte.CantImagenes.ToString()).SetFontSize(fontCellData);
                    document.Add(tableRegistros);
                    document.Close();

                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                    MessageBox.Show("Reporte generado correctamente \n en la ruta: " + rutaReporte, "Reporteria - Mis Ofertas");

                    //Uri test = new Uri(rutaReporte);
                    //WebBrowser.Navigate(rutaReporte);
                }
                catch (Exception err)
                {
                    MessageBox.Show("Se ha presentado un inconveniente al generar el reporet\nIntente nuevamente", "Reporteria - Mis Ofertas");
                }
            }
        }
示例#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
        private async void btnToPDF_Click(object sender, EventArgs e)
        {
            DateTime dateFrom = new DateTime(DateFrom.Value.Year, DateFrom.Value.Month, DateFrom.Value.Day, 00, 00, 01, 01);
            DateTime dateTo   = new DateTime(DateTo.Value.Year, DateTo.Value.Month, DateTo.Value.Day, 23, 59, 59, 59);


            var request = new Data.Requests.CompletedServicesSearchByDateRequest()
            {
                DateFrom     = dateFrom,
                DateTo       = dateTo,
                carServiceID = _carServiceID.GetValueOrDefault()
            };


            var model = await _EarningsOfCompletedServicesByDateService.Get <Data.Model.EarningsOfCompletedServices>(request);

            if (model.servicesList.Count() == 0)
            {
                MessageBox.Show("U odabranom periodu nema zarade niti od jedne usluge, te nije moguće procesirati izvještaj!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            var fileName = request.DateFrom.ToString("dd.MM.yyyy") + "_" + request.DateTo.ToString("dd.MM.yyyy") + ".pdf";
            var path     = "..\\..\\Reports\\izvjestaj_o_zaradi_" + fileName;

            PdfWriter   writer   = new PdfWriter(path);
            PdfDocument pdf      = new PdfDocument(writer);
            Document    document = new Document(pdf);

            iText.Layout.Element.Paragraph header = new iText.Layout.Element.Paragraph("Izvještaj o zaradi od obavljenih usluga u periodu " + request.DateFrom.ToString("dd.MM.yyyy.")
                                                                                       + " - " + request.DateTo.ToString("dd.MM.yyyy.")).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
            document.Add(header);

            float[] columnWidths             = { 5, 4 };
            iText.Layout.Element.Table table = new iText.Layout.Element.Table(UnitValue.CreatePercentArray(columnWidths));
            table.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);

            Cell[] headerFooter = new Cell[] {
                new Cell().SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Usluga")),
                new Cell().SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Zarada(u KM)")),
            };

            foreach (Cell hfCell in headerFooter)
            {
                table.AddHeaderCell(hfCell);
            }

            foreach (var x in model.servicesList)
            {
                table.AddCell(new Cell().SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).Add(new Paragraph(x.ServiceName)));
                table.AddCell(new Cell().SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).Add(new Paragraph(x.Earnings.ToString())));
            }



            document.Add(table);

            double suma = 0;

            foreach (var s in model.servicesList)
            {
                suma += s.Earnings;
            }

            Cell sum = new Cell(1, 7)
                       .Add(new Paragraph("Ukupno: " + suma.ToString() + " KM"))
                       .SetFontSize(13)
                       .SetFontColor(DeviceGray.BLACK)
                       .SetBackgroundColor(DeviceGray.WHITE)
                       .SetTextAlignment(TextAlignment.RIGHT)
                       .SetBold();

            document.Add(sum);


            MessageBox.Show("Uspješno ste kreirali izvještaj", "Kreiranje izvještaja", MessageBoxButtons.OK, MessageBoxIcon.Information);


            document.Close();

            System.Diagnostics.Process.Start(path);
        }
        protected void btnGenerarReporte_Click(object sender, EventArgs e)
        {
            MemoryStream ms = new MemoryStream();

            PdfWriter   pw  = new PdfWriter(ms);
            PdfDocument pdf = new PdfDocument(pw);
            Document    doc = new Document(pdf, PageSize.A4);

            doc.SetMargins(75, 35, 70, 35);
            string pathLogo = Server.MapPath("../Imagenes/Care Monitor.jpg");

            iText.Layout.Element.Image img = new iText.Layout.Element.Image(iText.IO.Image.ImageDataFactory.Create(pathLogo));

            pdf.AddEventHandler(PdfDocumentEvent.START_PAGE, new HeaderEventHandler(img));

            BE.Usuario usu = (BE.Usuario)Session["UsuarioEnSesion"];

            iText.Layout.Element.Table tabla = new iText.Layout.Element.Table(1).UseAllAvailableWidth();
            Cell cell = new Cell().Add(new Paragraph("Mediciones de " + usu.Nombre + " " + usu.Apellido).SetFontSize(14)
                                       .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                                       .SetBorder(Border.NO_BORDER));

            tabla.AddCell(cell);

            doc.Add(tabla);

            iText.Layout.Style styleCell = new iText.Layout.Style()
                                           .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                                           .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);

            iText.Layout.Element.Table _tabla = new iText.Layout.Element.Table(5).UseAllAvailableWidth();
            Cell _cell = new Cell().Add(new Paragraph("Fecha"));

            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Tipo"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Valor"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Máximo"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Mínimo"));
            _tabla.AddHeaderCell(_cell.AddStyle(styleCell));



            foreach (BE.Medicion bit in ListaMediciones)
            {
                _cell = new Cell().Add(new Paragraph(bit.Fecha.ToString("g")));
                _tabla.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(bit.Tipo.Nombre));
                _tabla.AddCell(_cell);
                if (bit.Valor < bit.Tipo.MinimoMasculino || bit.Valor > bit.Tipo.MaximoMasculino)
                {
                    _cell = new Cell().Add(new Paragraph(bit.Valor.ToString()));
                    _tabla.AddCell(_cell.SetBackgroundColor(ColorConstants.RED));
                }
                else
                {
                    _cell = new Cell().Add(new Paragraph(bit.Valor.ToString()));
                    _tabla.AddCell(_cell);
                }

                _cell = new Cell().Add(new Paragraph(bit.Tipo.MaximoMasculino.ToString()));
                _tabla.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(bit.Tipo.MinimoMasculino.ToString()));
                _tabla.AddCell(_cell);
            }

            doc.Add(_tabla);

            doc.Close();

            byte[] bytesStream = ms.ToArray();
            ms = new MemoryStream();
            ms.Write(bytesStream, 0, bytesStream.Length);
            ms.Position = 0;

            Response.AddHeader("content-disposition", "inline;filename=Reporte.pdf");
            Response.ContentType = "application/octectstream";
            Response.BinaryWrite(bytesStream);
            Response.End();
        }
示例#15
0
        private void btnReporteTienda_Click(object sender, RoutedEventArgs e)
        {
            if (!validarFechas())
            {
                MessageBox.Show("La fecha de inicio debe ser menor a la de termino\n Ingrese nuevamente", "Reporteria - Mis Ofertas");
                dpFechaInicio.Focus();
            }
            else
            {
                try
                {
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                    //---------------------SETEO DE REGISTROS PARA LA GENERACION DE LOS REPORTES----------------------------
                    List <ReporteTiendas>   listaConsumidoresRegistradosDia;
                    List <ReporteTiendas>   listaConsumidoresRegistradosMes;
                    List <HistorialCorreo>  listaCorreosEnviados;
                    List <ValoracionOferta> listaValoracionesPorEmpresa;
                    List <Rubro>            listaCuponesGeneradosPorRubro;

                    if (dpFechaInicio.SelectedDate == null && dpFechaTermino.SelectedDate == null)
                    {
                        listaConsumidoresRegistradosDia = reporteTiendasNeg.listaConsumidoresRegistradosDia(null, null);
                        listaConsumidoresRegistradosMes = reporteTiendasNeg.listaConsumidoresRegistradosMes(null, null);
                        listaCorreosEnviados            = historialCorreoNeg.listarCantCorreosEnviados(null, null);
                        listaValoracionesPorEmpresa     = reporteTiendasNeg.listaValoracionesPorEmpresa();
                        listaCuponesGeneradosPorRubro   = reporteTiendasNeg.listaCuponesGeneradosPorRubro();
                    }
                    else
                    {
                        listaConsumidoresRegistradosDia = reporteTiendasNeg.listaConsumidoresRegistradosDia(dpFechaInicio.SelectedDate, dpFechaTermino.SelectedDate);
                        listaConsumidoresRegistradosMes = reporteTiendasNeg.listaConsumidoresRegistradosMes(dpFechaInicio.SelectedDate, dpFechaTermino.SelectedDate);
                        listaCorreosEnviados            = historialCorreoNeg.listarCantCorreosEnviados(dpFechaInicio.SelectedDate, dpFechaTermino.SelectedDate);
                        listaValoracionesPorEmpresa     = reporteTiendasNeg.listaValoracionesPorEmpresa();
                        listaCuponesGeneradosPorRubro   = reporteTiendasNeg.listaCuponesGeneradosPorRubro();
                    }
                    //--------------------------------------------------------------------------------------------------------


                    String rutaDirectorioOferta             = "D:/MisOfertas/Reportes/";
                    List <ImagenOferta> listaImagenesOferta = new List <ImagenOferta>();
                    if (!Directory.Exists(rutaDirectorioOferta))
                    {
                        Directory.CreateDirectory(rutaDirectorioOferta);
                    }

                    DateTime fechaCreacionReporte = DateTime.Now;
                    String   rutaReporte          = rutaDirectorioOferta + "/ReporteTiendas" + fechaCreacionReporte.ToString("ddMMyyyyHHmm") + ".pdf";

                    PdfWriter   writer   = new PdfWriter(rutaReporte);
                    PdfDocument pdf      = new PdfDocument(writer);
                    Document    document = new Document(pdf, PageSize.A4);
                    PdfFont     font     = PdfFontFactory.CreateFont(FontConstants.TIMES_ROMAN);

                    string _filePath = System.IO.Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
                    _filePath  = Directory.GetParent(_filePath).FullName;
                    _filePath  = Directory.GetParent(_filePath).FullName;
                    _filePath += @"\img\MisOfertas-Letras.png";
                    document.Add(new iText.Layout.Element.Image(ImageDataFactory.Create(_filePath)).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.RIGHT).SetWidth(40).SetHeight(40));



                    document.Add(new iText.Layout.Element.Paragraph("Reporte resumenes por tiendas y empresas").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));
                    document.Add(new iText.Layout.Element.Paragraph(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()).SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(18));
                    float fontCell     = 11;
                    float fontCellData = 9;

                    //----------------TABLA CONSUMIDORES REGISTRADOR POR DIA-------------------------------
                    document.Add(new iText.Layout.Element.Paragraph("Consumidores registrados por dia").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));
                    float[] columnWidthsDIa = { 20f, 60f, 120f, 30f, 30f };

                    iText.Layout.Element.Table tableConsumidoresDia = new iText.Layout.Element.Table(5).SetFontSize(12);
                    tableConsumidoresDia.SetWidthPercent(100);
                    tableConsumidoresDia.SetFixedLayout();


                    Cell[] headerFooter = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Año").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Mes").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Dia").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Consumidores").SetFontSize(fontCell)
                    };

                    foreach (Cell hfCell in headerFooter)
                    {
                        tableConsumidoresDia.AddHeaderCell(hfCell);
                    }


                    for (int i = 0; i < listaConsumidoresRegistradosDia.Count; i++)
                    {
                        ReporteTiendas reporte = listaConsumidoresRegistradosDia[i];
                        tableConsumidoresDia.AddCell(i.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresDia.AddCell(reporte.AnioRegistro.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresDia.AddCell(reporte.MesRegistro.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresDia.AddCell(reporte.DiaRegistro.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresDia.AddCell(reporte.ConsumidoresRegistradosDia.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    document.Add(tableConsumidoresDia);


                    //----------------TABLA CONSUMIDORES REGISTRADOR POR MES-------------------------------
                    document.Add(new iText.Layout.Element.Paragraph("Consumidores registrados por mes").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));
                    float[] columnWidthsMes = { 20f, 60f, 120f, 30f };

                    iText.Layout.Element.Table tableConsumidoresMes = new iText.Layout.Element.Table(4).SetFontSize(12);
                    tableConsumidoresMes.SetWidthPercent(100);
                    tableConsumidoresMes.SetFixedLayout();


                    Cell[] cellsConsumidoresMes = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Año").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Mes").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Consumidores").SetFontSize(fontCell)
                    };

                    foreach (Cell hfCell in cellsConsumidoresMes)
                    {
                        tableConsumidoresMes.AddHeaderCell(hfCell);
                    }

                    for (int i = 0; i < listaConsumidoresRegistradosMes.Count; i++)
                    {
                        ReporteTiendas reporte = listaConsumidoresRegistradosMes[i];
                        tableConsumidoresMes.AddCell(i.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresMes.AddCell(reporte.AnioRegistro.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresMes.AddCell(reporte.MesRegistro.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableConsumidoresMes.AddCell(reporte.ConsumidoresRegistradosMes.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    document.Add(tableConsumidoresMes);

                    //----------------TABLA CANTIDAD CORREOS ENVIADOS POR TIENDA-EMPRESA -------------------------------
                    document.Add(new iText.Layout.Element.Paragraph("Sumatoria de correos enviados").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));
                    float[] columnWidthsCorreo = { 20f, 60f, 120f, 30f, 20f, 30f, 30f };

                    iText.Layout.Element.Table tableCorreoEnviados = new iText.Layout.Element.Table(7).SetFontSize(12);
                    tableCorreoEnviados.SetWidthPercent(100);
                    tableCorreoEnviados.SetFixedLayout();


                    Cell[] cellCorreoEnviados = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Empresa").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Local").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Oferta").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Codigo").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Fecha de Envio").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Correos enviados").SetFontSize(fontCell)
                    };


                    foreach (Cell hfCell in cellCorreoEnviados)
                    {
                        tableCorreoEnviados.AddHeaderCell(hfCell);
                    }

                    for (int i = 0; i < listaCorreosEnviados.Count; i++)
                    {
                        HistorialCorreo historialCorreo = listaCorreosEnviados[i];
                        Oferta          oferta          = historialCorreo.Oferta;
                        Local           local           = oferta.Local;
                        Empresa         empresa         = local.Empresa;

                        tableCorreoEnviados.AddCell(i.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(empresa.NombreEmpresa).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(local.NumeroLocal.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(oferta.TituloOferta).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(oferta.CodigoOferta.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(historialCorreo.FechaEnvio.ToShortDateString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCorreoEnviados.AddCell(historialCorreo.CantCorreosEnviados.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    document.Add(tableCorreoEnviados);

                    //----------------TABLA VALORACIONES POR EMPRESA Y LOCAL-------------------------------
                    document.Add(new iText.Layout.Element.Paragraph("Cantidad de Valoraciones por Empresas").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));


                    iText.Layout.Element.Table tableValoracionEmpresa = new iText.Layout.Element.Table(8).SetFontSize(12);
                    tableValoracionEmpresa.SetWidthPercent(100);
                    tableValoracionEmpresa.SetFixedLayout();


                    Cell[] cellEmpresa = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Rut").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Empresa").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Numero de Local").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Valoraciones Negativas").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Valoraciones Medias").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Valoraciones Positivas").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Valoraciones Totales").SetFontSize(fontCell)
                    };

                    foreach (Cell hfCell in cellEmpresa)
                    {
                        tableValoracionEmpresa.AddHeaderCell(hfCell);
                    }


                    for (int i = 0; i < listaValoracionesPorEmpresa.Count; i++)
                    {
                        ValoracionOferta valoracionOferta = listaValoracionesPorEmpresa[i];
                        Empresa          empresa          = valoracionOferta.Empresa;
                        Local            local            = valoracionOferta.Local;

                        tableValoracionEmpresa.AddCell(i.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(empresa.RutEmpresa.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(empresa.NombreEmpresa).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(local.NumeroLocal.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(valoracionOferta.CantValoracionesNegativas.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(valoracionOferta.CantValoracionMedias.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(valoracionOferta.CantValoracionesPositivas.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableValoracionEmpresa.AddCell(valoracionOferta.CantTotalValoraciones.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    document.Add(tableValoracionEmpresa);


                    //----------------TABLA CUPONES GENERADOS POR RUBRO-------------------------------
                    document.Add(new iText.Layout.Element.Paragraph("Cupones generados por Rubro").SetFont(font).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(20));


                    iText.Layout.Element.Table tableCupones = new iText.Layout.Element.Table(3).SetFontSize(12);
                    tableCupones.SetWidthPercent(100);
                    tableCupones.SetFixedLayout();


                    Cell[] cellsCupones = new Cell[] {
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("#").SetFontSize(fontCell).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Rubro").SetFontSize(fontCell),
                        new Cell().SetBackgroundColor(new DeviceGray(0.75f)).Add("Cupones Generados").SetFontSize(fontCell)
                    };

                    foreach (Cell hfCell in cellsCupones)
                    {
                        tableCupones.AddHeaderCell(hfCell);
                    }

                    for (int i = 0; i < listaCuponesGeneradosPorRubro.Count; i++)
                    {
                        Rubro rubro = listaCuponesGeneradosPorRubro[i];
                        tableCupones.AddCell(i.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCupones.AddCell(rubro.DescripcionRubro).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                        tableCupones.AddCell(rubro.CantidadCuponesGenerados.ToString()).SetFontSize(fontCellData).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                    }

                    document.Add(tableCupones);
                    document.Close();
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                    MessageBox.Show("Reporte generado correctamente \n en la ruta: " + rutaReporte, "Reporteria - Mis Ofertas");
                }
                catch (Exception err)
                {
                    MessageBox.Show("Se ha presentado un inconveniente al generar el reporet\nIntente nuevamente", "Reporteria - Mis Ofertas");
                }
            }
        }
示例#16
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);
        }
示例#17
0
        //private void Helper_GeneralSummary(GridViewRow row)
        //{
        //    row.BackColor = Color.Gray;
        //    row.Cells[0].HorizontalAlign = HorizontalAlign.Right;
        //    row.Cells[0].Text = "<b>Totale</b>";
        //    row.Cells[1].Text = "<b>" + row.Cells[1].Text + "</b>";
        //    row.Cells[2].Text = "<b>" + row.Cells[2].Text + "</b>";
        //    row.Cells[3].Text = "<b>" + row.Cells[3].Text + "</b>";
        //    row.Cells[4].Text = "<b>" + row.Cells[4].Text + "</b>";
        //    row.Cells[5].Text = "<b>" + row.Cells[5].Text + "</b>";
        //    //row.Cells[6].Text = "<b>" + row.Cells[6].Text + "</b>";
        //}

        protected void btnStampa_Click(object sender, EventArgs e)
        {
            try
            {
                Esito    esito         = new Esito();
                DateTime dataInizio    = DateTime.Parse(txt_DataInizio.Text);
                DateTime dataFine      = DateTime.Parse(txt_DataFine.Text);
                string   nominativo    = txt_Nominativo.Text;
                string   lavorazione   = txt_Lavorazione.Text;
                string   produzione    = txt_Produzione.Text;
                bool     soloFornitori = chk_Fornitore.Checked;

                List <DatiReport> listaDatiReport = Report_BLL.Instance.GetListaDatiReportCollaboratoriFornitori(dataInizio, dataFine, nominativo, lavorazione, produzione, soloFornitori, ref esito);

                Report_BLL.Instance.EliminaCollaboratoriImportoZero(ref listaDatiReport);

                if (esito.Codice == 0 && listaDatiReport != null && listaDatiReport.Count > 0)
                {
                    // LEGGO I PARAMETRI DI VS
                    Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA");
                    string pIvaVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE");
                    string denominazioneVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO");
                    string toponimoVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO");
                    string indirizzoVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO");
                    string civicoVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP");
                    string capVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA");
                    string cittaVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA");
                    string provinciaVs = cfAppo.valore;
                    cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL");
                    string emailVs = cfAppo.valore;

                    // export SU PDF

                    string nomeFile      = "Report_Collaboratori.pdf";
                    string pathReport    = ConfigurationManager.AppSettings["PATH_DOCUMENTI_REPORT"] + nomeFile;
                    string mapPathReport = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_REPORT"]) + nomeFile;

                    //string prefissoUrl = Request.Url.Scheme + "://" + Request.Url.Authority;
                    iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png"));


                    PdfWriter   wr  = new PdfWriter(mapPathReport);
                    PdfDocument doc = new PdfDocument(wr);
                    doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate());
                    //doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4);
                    Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4.Rotate(), false);

                    document.SetMargins(50, 30, 50, 30);

                    //iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(0, 225, 0);
                    // COLORE BLU VIDEOSYSTEM
                    iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243);

                    //CICLO LISTA DATI REPORT
                    int totCollaboratoriUtilizzati = 0;

                    foreach (DatiReport collaboratore in listaDatiReport)
                    {
                        totCollaboratoriUtilizzati++;
                        // AGGIUNGO TABLE PER LAYOUT INTESTAZIONE
                        iText.Layout.Element.Table tbIntestazione = new iText.Layout.Element.Table(new float[] { 1, 9 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        iText.Layout.Element.Image image          = new iText.Layout.Element.Image(imageData).ScaleAbsolute(100, 70).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);
                        Cell cellaImmagine = new Cell().SetVerticalAlignment(iText.Layout.Properties.VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);
                        cellaImmagine.Add(image);
                        tbIntestazione.AddCell(cellaImmagine);

                        iText.Layout.Element.Table tbIntestazioneDx = new iText.Layout.Element.Table(new float[] { 4, 6 }).UseAllAvailableWidth().SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        Paragraph pTitolo = new Paragraph("Nome").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        Paragraph pValore = new Paragraph(collaboratore.NomeCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        pTitolo = new Paragraph("Qualifica").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        pValore = new Paragraph(collaboratore.QualificaCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        pTitolo = new Paragraph("Indirizzo").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        pValore = new Paragraph(collaboratore.IndirizzoCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        pTitolo = new Paragraph("Città").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        pValore = new Paragraph(collaboratore.CittaCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        pTitolo = new Paragraph("Telefono").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        pValore = new Paragraph(collaboratore.TelefonoCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        pTitolo = new Paragraph("Cod.Fiscale/P.Iva").SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        tbIntestazioneDx.AddCell(pTitolo).SetBorder(iText.Layout.Borders.Border.NO_BORDER);
                        pValore = new Paragraph(collaboratore.CodFiscaleCollaboratore).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE);
                        tbIntestazioneDx.AddCell(pValore).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        // AGGIUNGO INTESTAZIONE COLLABORATORE
                        tbIntestazione.AddCell(tbIntestazioneDx).SetBorder(iText.Layout.Borders.Border.NO_BORDER);

                        document.Add(tbIntestazione);

                        Paragraph pSpazio = new Paragraph(" ");
                        document.Add(pSpazio);

                        Paragraph pLuogoData = new Paragraph(cittaVs + ", " + DateTime.Today.ToLongDateString());
                        document.Add(pLuogoData);

                        document.Add(pSpazio);

                        // CREAZIONE GRIGLIA
                        iText.Layout.Element.Table tbGrigla = new iText.Layout.Element.Table(new float[] { 67, 138, 120, 100, 100, 55, 50, 50, 50, 50 }).SetWidth(780).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetFixedLayout();
                        Paragraph pGriglia;
                        Cell      cellaGriglia;

                        // INTESTAZIONE GRIGLIA
                        pGriglia     = new Paragraph("Data").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Lavorazione").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Produzione").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Cliente").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Descrizione").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Assunz.").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Mista").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Rimb. KM").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Rit. Acconto").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        pGriglia     = new Paragraph("Fattura").SetFontSize(10);
                        cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddHeaderCell(cellaGriglia);

                        //pGriglia = new Paragraph("Diaria").SetFontSize(10);
                        //cellaGriglia = new iText.Layout.Element.Cell().SetBackgroundColor(coloreIntestazioni, 0.7f).SetBorder(new iText.Layout.Borders.SolidBorder(iText.Kernel.Colors.ColorConstants.WHITE, 1, 100)).SetPadding(5).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetBold();
                        //cellaGriglia.Add(pGriglia);
                        //tbGrigla.AddHeaderCell(cellaGriglia);

                        // TOTALI PARZIALI
                        decimal fattura         = 0;
                        decimal ritenutaAcconto = 0;
                        decimal assunzione      = 0;
                        decimal mista           = 0;
                        decimal rimborsoKm      = 0;
                        //int diaria = 0;

                        foreach (DatiFiscaliLavorazione datiFiscali in collaboratore.ListaDatiFiscali)
                        {
                            pGriglia     = new Paragraph(datiFiscali.DataLavorazione.ToShortDateString()).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            pGriglia     = new Paragraph(datiFiscali.Lavorazione).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            pGriglia     = new Paragraph(datiFiscali.Produzione).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            pGriglia     = new Paragraph(datiFiscali.Cliente).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            pGriglia     = new Paragraph(datiFiscali.Descrizione).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            assunzione  += datiFiscali.Assunzione;
                            pGriglia     = new Paragraph(datiFiscali.Assunzione.ToString("###,##0.00")).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            mista       += datiFiscali.Mista;
                            pGriglia     = new Paragraph(datiFiscali.Mista.ToString("###,##0.00")).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            rimborsoKm  += datiFiscali.RimborsoKm;
                            pGriglia     = new Paragraph(datiFiscali.RimborsoKm.ToString("###,##0.00")).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            ritenutaAcconto += datiFiscali.RitenutaAcconto;
                            pGriglia         = new Paragraph(datiFiscali.RitenutaAcconto.ToString("###,##0.00")).SetFontSize(9);
                            cellaGriglia     = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            fattura     += datiFiscali.Fattura;
                            pGriglia     = new Paragraph(datiFiscali.Fattura.ToString("###,##0.00")).SetFontSize(9);
                            cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            cellaGriglia.Add(pGriglia);
                            tbGrigla.AddCell(cellaGriglia);

                            //diaria += datiFiscali.Diaria;
                            //pGriglia = new Paragraph(datiFiscali.Diaria.ToString("###")).SetFontSize(9);
                            //cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                            //cellaGriglia.Add(pGriglia);
                            //tbGrigla.AddCell(cellaGriglia);
                        }

                        pGriglia     = new Paragraph("TOTALI").SetFontSize(9);
                        cellaGriglia = new Cell(1, 5).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        pGriglia     = new Paragraph(assunzione.ToString("###,##0.00")).SetFontSize(9);
                        cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        pGriglia     = new Paragraph(mista.ToString("###,##0.00")).SetFontSize(9);
                        cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        pGriglia     = new Paragraph(rimborsoKm.ToString("###,##0.00")).SetFontSize(9);
                        cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        pGriglia     = new Paragraph(ritenutaAcconto.ToString("###,##0.00")).SetFontSize(9);
                        cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        pGriglia     = new Paragraph(fattura.ToString("###,##0.00")).SetFontSize(9);
                        cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        cellaGriglia.Add(pGriglia);
                        tbGrigla.AddCell(cellaGriglia);

                        //pGriglia = new Paragraph(diaria.ToString("##0")).SetFontSize(9);
                        //cellaGriglia = new Cell().SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetPadding(5).SetBackgroundColor(iText.Kernel.Colors.ColorConstants.WHITE, 10).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetBold();
                        //cellaGriglia.Add(pGriglia);
                        //tbGrigla.AddCell(cellaGriglia);

                        // AGGIUNGO TABELLA
                        document.Add(tbGrigla);

                        if (totCollaboratoriUtilizzati < listaDatiReport.Count)
                        {
                            // AGGIUNGO SALTO PAGINA
                            document.Add(new AreaBreak());
                        }
                    }

                    int n = doc.GetNumberOfPages();
                    iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize();

                    // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA
                    for (int i = 1; i <= n; i++)
                    {
                        //AGGIUNGO NUM.PAGINA
                        document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7),
                                                 pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0);
                        //AGGIUNGO FOOTER
                        document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                                                 pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0);
                    }

                    // CHIUDO IL PDF
                    document.Flush();
                    document.Close();
                    wr.Close();

                    btnRicerca_Click(null, null);

                    // CREO STRINGA PER IL JAVASCRIPT DI VISUALIZZAZIONE
                    if (System.IO.File.Exists(mapPathReport))
                    {
                        Page page = HttpContext.Current.Handler as Page;
                        ScriptManager.RegisterStartupScript(page, page.GetType(), "apriPdf", script: "window.open('" + pathReport.Replace("~", "") + "')", addScriptTags: true);
                    }
                    else
                    {
                        esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                        esito.Descrizione = "Il File " + pathReport.Replace("~", "") + " non è stato creato correttamente!";
                        BasePage p = new BasePage();
                        p.ShowError(esito.Descrizione);
                    }
                }
            }
            catch (Exception ex)
            {
                BasePage p = new BasePage();
                p.ShowError(ex.Message + " " + ex.StackTrace);
            }
        }
示例#18
0
        public Esito popolaPannelloGiornata()
        {
            Esito esito = new Esito();

            try
            {
                // LEGGO I PARAMETRI DI VS
                Config cfAppo = Config_BLL.Instance.getConfig(ref esito, "PARTITA_IVA");
                string pIvaVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "DENOMINAZIONE");
                string denominazioneVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "TOPONIMO");
                string toponimoVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "INDIRIZZO");
                string indirizzoVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "CIVICO");
                string civicoVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "CAP");
                string capVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "CITTA");
                string cittaVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "PROVINCIA");
                string provinciaVs = cfAppo.valore;
                cfAppo = Config_BLL.Instance.getConfig(ref esito, "EMAIL");
                string emailVs = cfAppo.valore;

                // GESTIONE NOMI FILE PDF
                string nomeFile        = "RiepilogoGiornata.pdf";
                string pathGiornata    = ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"] + nomeFile;
                string mapPathGiornata = MapPath(ConfigurationManager.AppSettings["PATH_DOCUMENTI_PROTOCOLLO"]) + nomeFile;

                iText.IO.Image.ImageData imageData = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/logoVSP_trim.png"));
                iText.IO.Image.ImageData imageDNV  = iText.IO.Image.ImageDataFactory.Create(MapPath("~/Images/DNV_2008_ITA2.jpg"));


                PdfWriter   wr  = new PdfWriter(mapPathGiornata);
                PdfDocument doc = new PdfDocument(wr);
                doc.SetDefaultPageSize(iText.Kernel.Geom.PageSize.A4.Rotate());
                //Document document = new Document(doc);
                Document document = new Document(doc, iText.Kernel.Geom.PageSize.A4.Rotate(), false);

                // IMPOSTO LA DATA DI OGGI SE PRIMA ELABORAZIONE
                if (string.IsNullOrEmpty(tbDataElaborazione.Text.Trim()))
                {
                    tbDataElaborazione.Text = DateTime.Today.ToShortDateString();
                }

                document.SetMargins(90, 35, 50, 35);

                Paragraph pSpazio = new Paragraph("");
                document.Add(pSpazio);

                // COLORE BLU VIDEOSYSTEM
                iText.Kernel.Colors.Color coloreIntestazioni = new iText.Kernel.Colors.DeviceRgb(33, 150, 243);


                DateTime dataTmp  = Convert.ToDateTime(tbDataElaborazione.Text.Trim());
                string   sDataTmp = dataTmp.ToString("yyyy-MM-dd") + "T00:00:00.000";

                string queryRicerca = "select dal.descrizione as qualifica,ac.cognome as cognome_operatore, ac.nome as nome_operatore, da.codice_lavoro,produzione,lavorazione " +
                                      //", da.durata_lavorazione as Durata , ca.nome,ts.nome,tt.nome " +
                                      //", ac.cognome as cognome_operatore,ac.nome as nome_operatore, dal.descrizioneLunga " +
                                      "from[dbo].[tab_dati_agenda] da " +
                                      "left join tipo_colonne_agenda ca " +
                                      "on da.id_colonne_agenda = ca.id " +
                                      "left join tipo_stato ts " +
                                      "on da.id_stato = ts.id " +
                                      "left join tipo_tipologie tt " +
                                      "on da.id_tipologia = tt.id " +
                                      "left join dati_lavorazione dl " +
                                      "on dl.idDatiAgenda = da.id " +
                                      "left join dati_articoli_lavorazione dal " +
                                      "on dl.id = dal.idDatiLavorazione " +
                                      "left join anag_collaboratori ac " +
                                      "on dal.idCollaboratori = ac.id " +
                                      "where ac.cognome is not null and dal.descrizione<> 'Diaria' " +
                                      "and data_inizio_lavorazione <= '@dataElaborazione' and data_fine_lavorazione >= '@dataElaborazione' " +
                                      //"order by codice_lavoro, dal.descrizione, ac.cognome, ac.nome";
                                      "group by dal.descrizione ,ac.cognome, ac.nome, da.codice_lavoro,produzione,lavorazione " +
                                      //"order by qualifica,ac.cognome, ac.nome, codice_lavoro";
                                      "order by codice_lavoro,qualifica,ac.cognome, ac.nome";
                queryRicerca = queryRicerca.Replace("@dataElaborazione", sDataTmp);

                esito = new Esito();
                DataTable dtProtocolli = Base_DAL.GetDatiBySql(queryRicerca, ref esito);
                if (dtProtocolli != null && dtProtocolli.Rows != null && dtProtocolli.Rows.Count > 0)
                {
                    // INTESTAZIONE GRIGLIA
                    iText.Layout.Element.Table table = new iText.Layout.Element.Table(3).UseAllAvailableWidth();
                    //Paragraph intestazione = new Paragraph("Codice Lavoro").SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);
                    //table.AddHeaderCell(intestazione);

                    //intestazione = new Paragraph("Produzione").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);
                    //table.AddHeaderCell(intestazione);
                    //intestazione = new Paragraph("Lavorazione").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);
                    //table.AddHeaderCell(intestazione);
                    Paragraph intestazione = new Paragraph("Qualifica").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);
                    table.AddHeaderCell(intestazione);
                    intestazione = new Paragraph("Cognome").SetFontSize(10).SetBold().SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);
                    table.AddHeaderCell(intestazione);
                    intestazione = new Paragraph("Nome").SetFontSize(10).SetFontSize(10).SetBold().SetBackgroundColor(coloreIntestazioni, 0.7f);

                    table.AddHeaderCell(intestazione);


                    string codice_lavoro = "";
                    foreach (DataRow riga in dtProtocolli.Rows)
                    {
                        string qualifica = "";
                        string cognome   = "";
                        string nome      = "";

                        string produzione  = "";
                        string lavorazione = "";


                        //Cell cellaQualifica = new Cell();
                        //if (!riga["qualifica"].ToString().ToUpper().Equals(qualifica.ToUpper()))
                        //{
                        //    Paragraph pQualifica = new Paragraph(riga["qualifica"].ToString()).SetFontSize(8).SetBold();
                        //    cellaQualifica.Add(pQualifica);
                        //    qualifica = riga["qualifica"].ToString();
                        //}
                        //else
                        //{
                        //    Paragraph pQualifica = new Paragraph("").SetFontSize(8).SetBold();
                        //    cellaQualifica.Add(pQualifica);
                        //}
                        //table.AddCell(cellaQualifica);

                        Cell cellaLavorazione = new Cell(1, 3);
                        if (!riga["codice_lavoro"].ToString().ToUpper().Equals(codice_lavoro.ToUpper()))
                        {
                            if (riga["produzione"] != null)
                            {
                                produzione = riga["produzione"].ToString();
                            }
                            if (riga["lavorazione"] != null)
                            {
                                lavorazione = riga["lavorazione"].ToString();
                            }
                            Paragraph pCodiceLavoro = new Paragraph(riga["codice_lavoro"].ToString() + " - Produzione: " + produzione + " - Lavorazione: " + lavorazione).SetFontSize(10).SetBold();
                            cellaLavorazione.Add(pCodiceLavoro).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                            codice_lavoro = riga["codice_lavoro"].ToString();
                            table.AddCell(cellaLavorazione);
                        }
                        //else
                        //{
                        //    Paragraph pCodiceLavoro = new Paragraph("").SetFontSize(8).SetBold();
                        //    cellaLavorazione.Add(pCodiceLavoro);
                        //}
                        //table.AddCell(cellaLavorazione);

                        if (riga["qualifica"] != null)
                        {
                            qualifica = riga["qualifica"].ToString();
                        }
                        if (riga["cognome_operatore"] != null)
                        {
                            cognome = riga["cognome_operatore"].ToString();
                        }
                        if (riga["nome_operatore"] != null)
                        {
                            nome = riga["nome_operatore"].ToString();
                        }



                        //table.AddCell(produzione).SetFontSize(8);
                        //table.AddCell(lavorazione).SetFontSize(8);
                        Cell      cellaQualifica = new Cell();
                        Paragraph pQualifica     = new Paragraph(qualifica).SetFontSize(9).SetBold();
                        cellaQualifica.Add(pQualifica).SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                        table.AddCell(cellaQualifica);


                        table.AddCell(cognome).SetFontSize(9);
                        table.AddCell(nome).SetFontSize(9);
                    }
                    document.Add(table);
                }

                int n = doc.GetNumberOfPages();
                iText.Kernel.Geom.Rectangle pageSize = doc.GetPage(n).GetPageSize();

                // AGGIUNGO CONTEGGIO PAGINE E FOOTER PER OGNI PAGINA
                for (int i = 1; i <= n; i++)
                {
                    // AGGIUNGO LOGO
                    iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData).ScaleAbsolute(60, 60).SetFixedPosition(i, 20, pageSize.GetHeight() - 80);
                    document.Add(image);

                    // AGGIUNGO LOGO DNV
                    iText.Layout.Element.Image logoDnv = new iText.Layout.Element.Image(imageDNV).ScaleAbsolute(40, 40).SetFixedPosition(i, 780, 8);
                    document.Add(logoDnv);

                    //AGGIUNGO NUM.PAGINA
                    document.ShowTextAligned(new Paragraph("pagina " + i.ToString() + " di " + n.ToString()).SetFontSize(7), pageSize.GetWidth() - 60, pageSize.GetHeight() - 20, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0);

                    // AGGIUNGO TITOLO
                    document.ShowTextAligned(new Paragraph("OPERATORI IMPEGNATI PER IL " + tbDataElaborazione.Text.Trim()).SetFontSize(11), 400, pageSize.GetHeight() - 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0);

                    //AGGIUNGO FOOTER
                    document.ShowTextAligned(new Paragraph(denominazioneVs + " P.IVA " + pIvaVs + Environment.NewLine + "Sede legale: " + toponimoVs + " " + indirizzoVs + " " + civicoVs + " - " + capVs + " " + cittaVs + " " + provinciaVs + " e-mail: " + emailVs).SetFontSize(7).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER),
                                             pageSize.GetWidth() / 2, 30, i, iText.Layout.Properties.TextAlignment.CENTER, iText.Layout.Properties.VerticalAlignment.TOP, 0);

                    if (i == n)
                    {
                        // ULTIMA PAGINA
                    }
                }

                document.Close();
                wr.Close();

                if (File.Exists(mapPathGiornata))
                {
                    framePdfGiornata.Attributes.Remove("src");
                    framePdfGiornata.Attributes.Add("src", pathGiornata.Replace("~", ""));

                    DivFramePdfGiornata.Visible = true;
                    framePdfGiornata.Visible    = true;

                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "aggiornaFrame", script: "javascript: document.getElementById('" + framePdfGiornata.ClientID + "').contentDocument.location.reload(true);", addScriptTags: true);
                    btnStampaGiornata.Attributes.Add("onclick", "window.open('" + pathGiornata.Replace("~", "") + "');");
                    //}
                }
                else
                {
                    esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                    esito.Descrizione = "Il File " + pathGiornata.Replace("~", "") + " non è stato creato correttamente!";
                }
            }
            catch (Exception ex)
            {
                esito.Codice      = Esito.ESITO_KO_ERRORE_GENERICO;
                esito.Descrizione = "popolaPannelloGiornata() " + ex.Message + Environment.NewLine + ex.StackTrace;
            }

            return(esito);
        }