private void OnDriverSelectCheckedChanged(object parameter)
        {
            SelectableDriver selectableDriver = parameter as SelectableDriver;

            selectableDriver.IsSelected = !selectableDriver.IsSelected;

            if (Drivers.All(x => x.IsSelected))
            {
                IsAllSelected = true;
            }
            else if (Drivers.Count(x => x.IsSelected) > 0)
            {
                IsAllSelected = null;
            }
            else
            {
                IsAllSelected = false;
            }

            EnableDisableReportTypeDropdown();
        }
示例#2
0
        public static void DetailedLessonReport(SelectableDriver driver, string absoluteFileName)
        {
            using (PdfWriter writer = new PdfWriter(absoluteFileName))
            {
                PdfDocument pdf = new PdfDocument(writer);

                // Create an instance of the document class which represents the PDF document itself.
                Document document = new Document(pdf, PageSize.A4);

                AddMetaInformationForDocument(pdf, "Detailed Lesson Report", "Driver's Detailed Lesson Report");

                Paragraph titlePhrase = new Paragraph();
                Text      reportTitle = new Text("Detailed Lesson Report").AddStyle(titleStyle);
                Text      dateTime    = new Text($"\n{DateTime.Now.ToString(DateFormat)}").AddStyle(infoStyle);

                titlePhrase.Add(reportTitle);
                titlePhrase.Add(dateTime);

                Paragraph driverName     = new Paragraph();
                Text      driverNameText = new Text($"{driver.LastName}, {driver.FirstName}\n\n").AddStyle(titleStyle);
                driverName.SetTextAlignment(TextAlignment.CENTER);
                driverName.Add(driverNameText);

                try
                {
                    document.Add(titlePhrase);
                    document.Add(driverName);

                    Table pdfPTable = new Table(5);
                    pdfPTable.SetWidth(iText.Layout.Properties.UnitValue.CreatePercentValue(100f));

                    //Adding Headers Here.
                    pdfPTable.AddCell(GetHeaderCell("Lesson"));
                    pdfPTable.AddCell(GetHeaderCell("High Score"));
                    pdfPTable.AddCell(GetHeaderCell("# of Attempts"));
                    pdfPTable.AddCell(GetHeaderCell("Total Time (m)"));
                    pdfPTable.AddCell(GetHeaderCell("Date Completed"));
                    // Headers Completed...

                    // Adding data now.
                    foreach (GroupedAttemptsByLesson attempt in driver.GroupedAttemptsByLessons)
                    {
                        pdfPTable.AddCell(GetContentCell(attempt.Lesson.Name));
                        pdfPTable.AddCell(GetContentCell(attempt.HighScore.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        pdfPTable.AddCell(GetContentCell(attempt.TotalAttempts.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        pdfPTable.AddCell(GetContentCell(attempt.TotalTimes.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        pdfPTable.AddCell(GetContentCell(attempt.DateCompleted != null ? attempt.DateCompleted?.ToString("dd-MMM-yyyy") : string.Empty, iText.Layout.Properties.TextAlignment.RIGHT));

                        if (attempt.GroupedInfractions == null || attempt.GroupedInfractions.Count == 0)
                        {
                            continue;
                        }

                        // Adding Infractions now.
                        Table infractionsTable = new Table(3);
                        infractionsTable.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);

                        //Adding infractions Headers Here.
                        infractionsTable.AddCell(GetHeaderCell("Infractions"));
                        infractionsTable.AddCell(GetHeaderCell("# of Occurrences"));
                        infractionsTable.AddCell(GetHeaderCell("Points Deducted"));
                        // Headers Completed...

                        foreach (GroupedInfractions groupedInfractions in attempt.GroupedInfractions)
                        {
                            infractionsTable.AddCell(GetContentCell(groupedInfractions.Infraction.Name));
                            infractionsTable.AddCell(GetContentCell(groupedInfractions.Occurances.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                            infractionsTable.AddCell(GetContentCell(groupedInfractions.Deduction.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        }

                        // Adding Total
                        infractionsTable.AddCell(GetContentCell(string.Empty));
                        infractionsTable.AddCell(GetContentCell("Total"));
                        Cell boldCell = GetContentCell(attempt.TotalDeduction.ToString(), iText.Layout.Properties.TextAlignment.RIGHT);
                        boldCell.AddStyle(boldInfoStyle);
                        infractionsTable.AddCell(boldCell);

                        Cell infractionTableCell = new Cell(1, 5);
                        infractionTableCell.SetPadding(25);
                        infractionTableCell.Add(infractionsTable);

                        pdfPTable.AddCell(infractionTableCell);
                    }

                    document.Add(pdfPTable);
                    AddPageNumbers(pdf, document);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    document.Close();
                    writer.Close();
                }
            }
        }
示例#3
0
        public static void IndividualDriversReport(SelectableDriver driver, string absoluteFileName)
        {
            using (PdfWriter writer = new PdfWriter(absoluteFileName))
            {
                PdfDocument pdf = new PdfDocument(writer);

                // Create an instance of the document class which represents the PDF document itself.
                Document document = new Document(pdf, PageSize.A4);

                AddMetaInformationForDocument(pdf, "Individual Driver Report", "Indvidual Driver Report");

                Paragraph titlePhrase = new Paragraph();
                Text      reportTitle = new Text("Individual Driver Report").AddStyle(titleStyle);
                Text      dateTime    = new Text($"\n{DateTime.Now.ToString(DateFormat)}").AddStyle(infoStyle);

                titlePhrase.Add(reportTitle);
                titlePhrase.Add(dateTime);

                Paragraph driverName     = new Paragraph();
                Text      driverNameText = new Text($"{driver.LastName}, {driver.FirstName}\n\n").AddStyle(titleStyle);
                driverName.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                driverName.Add(driverNameText);

                try
                {
                    document.Add(titlePhrase);
                    document.Add(driverName);

                    Table pdfPTable = new Table(5);
                    pdfPTable.SetWidth(iText.Layout.Properties.UnitValue.CreatePercentValue(100f));

                    //Adding Headers Here.
                    pdfPTable.AddCell(GetHeaderCell("Lesson"));
                    pdfPTable.AddCell(GetHeaderCell("High Score"));
                    pdfPTable.AddCell(GetHeaderCell("# of Attempts"));
                    pdfPTable.AddCell(GetHeaderCell("Total Time (m)"));
                    pdfPTable.AddCell(GetHeaderCell("Date Completed"));
                    // Headers Completed...

                    // Adding data now.
                    foreach (GroupedAttemptsByLesson attempt in driver.GroupedAttemptsByLessons)
                    {
                        pdfPTable.AddCell(GetContentCell(attempt.Lesson.Name));
                        pdfPTable.AddCell(GetContentCell(attempt.HighScore.ToString(), iText.Layout.Properties.TextAlignment.CENTER));
                        pdfPTable.AddCell(GetContentCell(attempt.TotalAttempts.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        pdfPTable.AddCell(GetContentCell(attempt.TotalTimes.ToString(), iText.Layout.Properties.TextAlignment.RIGHT));
                        pdfPTable.AddCell(GetContentCell(attempt.DateCompleted != null ? attempt.DateCompleted?.ToString("dd-MMM-yyyy") : string.Empty, iText.Layout.Properties.TextAlignment.RIGHT));
                    }

                    document.Add(pdfPTable);
                    AddPageNumbers(pdf, document);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    document.Close();
                    writer.Close();
                }
            }
        }