public byte[] EstraiVerniciaturaReport(VerniciaturaReportModel report, DateTime dataInizio, DateTime dataFine) { InizializzaDocumento("Report Verniciatura", "Report settimanale", "MetalWeb"); _document.DefaultPageSetup.Orientation = Orientation.Landscape; _document.DefaultPageSetup.RightMargin = 20; _document.DefaultPageSetup.LeftMargin = 20; _document.AddSection(); _document.LastSection.AddParagraph("Report Verniciatura", "Heading2"); Paragraph paragraph = _document.LastSection.AddParagraph(); paragraph.AddText("Report per la settimana dal "); paragraph.AddFormattedText(dataInizio.ToShortDateString(), TextFormat.Bold); paragraph.AddText(" al "); paragraph.AddFormattedText(dataFine.ToShortDateString(), TextFormat.Bold); paragraph.AddText(". Quantità manuale complessiva: "); paragraph.AddFormattedText(report.QuantitaManualeTotale, TextFormat.Bold); paragraph.AddText(". NUmero di barre complessivo: "); paragraph.AddFormattedText(report.BarreTotali, TextFormat.Bold); paragraph.Format.SpaceAfter = "1cm"; CreaTabellaVerniciatura(report); byte[] fileContents = EstraiByteDaDocumento(); return(fileContents); }
public ActionResult TrovaConsuntivo(int Anno, int Settimana) { VerniciaturaBLL bll = new VerniciaturaBLL(); DateTime dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana); DateTime dataFine = dataInizioSettimana.AddDays(7); VerniciaturaReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine); ViewData.Add("dataInizio", dataInizioSettimana.ToShortDateString()); ViewData.Add("dataFine", dataFine.ToShortDateString()); return(PartialView("GrigliaReportPartial", report)); }
public FileResult ReportPDF(int Anno, int Settimana) { VerniciaturaBLL bll = new VerniciaturaBLL(); DateTime dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana); DateTime dataFine = dataInizioSettimana.AddDays(7); VerniciaturaReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine); PDFHelper pdfHelper = new PDFHelper(); byte[] fileContents = pdfHelper.EstraiVerniciaturaReport(report, dataInizioSettimana, dataFine); return(File(fileContents, "application/pdf", "Report.pdf")); }
private void CreaTabellaVerniciatura(VerniciaturaReportModel report) { //12 colonne Table table = new Table(); table.Borders.Width = 0.75; Column column = table.AddColumn(Unit.FromCentimeter(2)); column.Format.Alignment = ParagraphAlignment.Center; column = table.AddColumn(Unit.FromCentimeter(3.5)); column.Format.Alignment = ParagraphAlignment.Center; column = table.AddColumn(Unit.FromCentimeter(2.5)); column.Format.Alignment = ParagraphAlignment.Center; table.Rows.Height = 10; table.TopPadding = 5; table.BottomPadding = 5; Row row = table.AddRow(); row.Shading.Color = Colors.PaleGoldenrod; Cell cell = row.Cells[0]; cell.AddParagraph("Giorno"); cell = row.Cells[1]; cell.AddParagraph("Quantità manuale"); cell = row.Cells[2]; cell.AddParagraph("Barre"); foreach (VerniciaturaConsuntivoModel consuntivo in report.Consuntivo) { row = table.AddRow(); cell = row.Cells[0]; cell.AddParagraph(consuntivo.Giorno.ToShortDateString()); cell.VerticalAlignment = VerticalAlignment.Center; cell = row.Cells[1]; cell.AddParagraph(consuntivo.QuantitaManuale.ToString()); cell = row.Cells[2]; cell.AddParagraph(consuntivo.Barre.ToString()); } table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); _document.LastSection.Add(table); }
public VerniciaturaReportModel EstraiConsutivo(DateTime dataInizio, DateTime dataFine) { List <VerniciaturaConsuntivoModel> consuntivo = new List <VerniciaturaConsuntivoModel>(); VerniciaturaDS ds = new VerniciaturaDS(); using (VerniciaturaBusiness bPDV = new VerniciaturaBusiness()) { bPDV.FillRW_VERNICIATURA_CONSUNTIVO(ds); } List <VerniciaturaDS.RW_VERNICIATURA_CONSUNTIVORow> elementiTrovati = ds.RW_VERNICIATURA_CONSUNTIVO.Where(X => X.GIORNO >= dataInizio && X.GIORNO < dataFine).ToList(); int quantitaTotale = 0; int barreTotali = 0; foreach (VerniciaturaDS.RW_VERNICIATURA_CONSUNTIVORow m in elementiTrovati) { VerniciaturaConsuntivoModel model = new VerniciaturaConsuntivoModel(); model.Giorno = m.GIORNO; model.QuantitaManuale = (int)m.QUANTITA_MANUALE; model.Barre = (int)m.BARRE; model.IdConsuntivo = (int)m.IDCONSUNTIVO; consuntivo.Add(model); quantitaTotale += model.QuantitaManuale; barreTotali += model.Barre; } VerniciaturaReportModel report = new VerniciaturaReportModel(); report.Consuntivo = consuntivo; report.BarreTotali = barreTotali.ToString(); report.QuantitaManualeTotale = quantitaTotale.ToString(); return(report); }