public byte[] EstraiPDVReport(PVDReportModel report, DateTime dataInizio, DateTime dataFine) { InizializzaDocumento("Report PDV", "Report settimanale", "MetalWeb"); _document.DefaultPageSetup.Orientation = Orientation.Landscape; _document.DefaultPageSetup.RightMargin = 20; _document.DefaultPageSetup.LeftMargin = 20; _document.AddSection(); _document.LastSection.AddParagraph("Report PVD", "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(". Durata complessiva: "); paragraph.AddFormattedText(report.DurataTotale, TextFormat.Bold); paragraph.Format.SpaceAfter = "1cm"; CreaTabellaPVD(report); byte[] fileContents = EstraiByteDaDocumento(); return(fileContents); }
public ActionResult TrovaConsuntivo(int Anno, int Settimana, string Macchina) { PVDBLL bll = new PVDBLL(); DateTime dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana); DateTime dataFine = dataInizioSettimana.AddDays(7); PVDReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine, Macchina); ViewData.Add("dataInizio", dataInizioSettimana.ToShortDateString()); ViewData.Add("dataFine", dataFine.ToShortDateString()); return(PartialView("GrigliaReportPartial", report)); }
public FileResult ReportPDF(int Anno, int Settimana, string Macchina) { PVDBLL bll = new PVDBLL(); DateTime dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana); DateTime dataFine = dataInizioSettimana.AddDays(7); PVDReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine, Macchina); PDFHelper pdfHelper = new PDFHelper(); byte[] fileContents = pdfHelper.EstraiPDVReport(report, dataInizioSettimana, dataFine); return(File(fileContents, "application/pdf", "Report.pdf")); }
public PVDReportModel EstraiConsutivo(DateTime dataInizio, DateTime dataFine, string Macchina) { List <PVDConsuntivoModel> consuntivo = new List <PVDConsuntivoModel>(); PVDDS ds = new PVDDS(); using (PVDBusiness bPDV = new PVDBusiness()) { bPDV.FillRW_PVD_CONSUNTIVO(ds); } List <PVDDS.RW_PVD_CONSUNTIVORow> elementiTrovati = ds.RW_PVD_CONSUNTIVO.Where(X => X.GIORNO >= dataInizio && X.GIORNO < dataFine).ToList(); if (!string.IsNullOrEmpty(Macchina)) { elementiTrovati = elementiTrovati.Where(x => x.IDRESOURCEF == Macchina).ToList(); } TimeSpan durataTotale = new TimeSpan(); foreach (PVDDS.RW_PVD_CONSUNTIVORow m in elementiTrovati) { PVDConsuntivoModel model = new PVDConsuntivoModel(); TimeSpan durata = DateTimeHelper.CalcolaDurata(m.INIZIO, m.FINE); durataTotale = durataTotale.Add(durata); model.Giorno = m.GIORNO; model.IDRESOURCEF = m.IDRESOURCEF; model.Macchina = m.MACCHINA; model.FinituraCodice = m.IsFINITURA_CODNull() ? string.Empty : m.FINITURA_COD; model.FinituraDescrizione = m.IsFINITURA_DESCNull() ? string.Empty : m.FINITURA_DESC; model.TipoCiclo = m.IsTIPONull() ? string.Empty : m.TIPO; model.Inizio = m.INIZIO; model.Fine = m.FINE; model.Quantita = (int)m.QUANTITA; model.Clienti = m.IsCLIENTINull() ? string.Empty : m.CLIENTI; model.Articolo = m.IsARTICOLONull() ? string.Empty : m.ARTICOLO; model.Impegno = m.IMPEGNO; model.IdConsuntivo = (int)m.IDCONSUNTIVO; model.Durata = durata.ToString(@"hh\:mm"); consuntivo.Add(model); } PVDReportModel report = new PVDReportModel(); report.Consuntivo = consuntivo; report.DurataTotale = DateTimeHelper.ToHoursMin(durataTotale); return(report); }
private void CreaTabellaPVD(PVDReportModel report) { //12 colonne Table table = new Table(); table.Borders.Width = 0.75; Column column = table.AddColumn(Unit.FromCentimeter(2)); column.Format.Alignment = ParagraphAlignment.Center; table.AddColumn(Unit.FromCentimeter(4.5)); table.AddColumn(Unit.FromCentimeter(4.5)); table.AddColumn(Unit.FromCentimeter(3)); table.AddColumn(Unit.FromCentimeter(2)); table.AddColumn(Unit.FromCentimeter(2)); table.AddColumn(Unit.FromCentimeter(2)); table.AddColumn(Unit.FromCentimeter(2)); table.AddColumn(Unit.FromCentimeter(2.5)); 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("Macchina"); cell = row.Cells[2]; cell.AddParagraph("Finitura"); cell = row.Cells[3]; cell.AddParagraph("Ciclo"); cell = row.Cells[4]; cell.AddParagraph("Inizio"); cell = row.Cells[5]; cell.AddParagraph("Fine"); cell = row.Cells[6]; cell.AddParagraph("Durata"); cell = row.Cells[7]; cell.AddParagraph("Quantità"); cell = row.Cells[8]; cell.AddParagraph("Impegno"); foreach (PVDConsuntivoModel consuntivo in report.Consuntivo) { row = table.AddRow(); cell = row.Cells[0]; cell.AddParagraph(consuntivo.Giorno.ToShortDateString()); cell.VerticalAlignment = VerticalAlignment.Center; cell.MergeDown = 1; cell = row.Cells[1]; cell.AddParagraph(consuntivo.Macchina); cell = row.Cells[2]; cell.AddParagraph(string.Format("{0}-{1}", consuntivo.FinituraCodice, consuntivo.FinituraDescrizione)); cell = row.Cells[3]; cell.AddParagraph(consuntivo.TipoCiclo); cell = row.Cells[4]; cell.AddParagraph(consuntivo.Inizio); cell = row.Cells[5]; cell.AddParagraph(consuntivo.Fine); cell = row.Cells[6]; cell.AddParagraph(consuntivo.Durata); cell = row.Cells[7]; cell.AddParagraph(consuntivo.Quantita.ToString()); cell = row.Cells[8]; cell.AddParagraph(consuntivo.Impegno); row = table.AddRow(); cell = row.Cells[1]; cell.MergeRight = 2; Paragraph p = cell.AddParagraph(); p.AddFormattedText("Clienti: ", TextFormat.Bold); p.AddText(consuntivo.Clienti); cell = row.Cells[4]; cell.MergeRight = 4; p = cell.AddParagraph(); p.AddFormattedText("Articoli: ", TextFormat.Bold); p.AddText(consuntivo.Articolo); } table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 1.5, Colors.Black); _document.LastSection.Add(table); }