Exemplo n.º 1
0
        private void cmdAll_Click(object sender, EventArgs e)
        {
            try
            {
                acracsReport = new ACRACS_Report();
                SectionReport _tmpSectionReport;

                // For every section, generate a report.
                for (int i = 0; i < sections.Count; i++)
                {
                    // Get classes and courses of the section.
                    GetClasses(sections[i]);
                    GetCourses(sections[i]);

                    // determine if classes has saturday or sunday
                    for (int y = 0; y < classes.Count; y++)
                    {
                        if (classes[y].Day == "Saturday" || classes[y].Day == "Sunday")
                        {
                            hasweekend = true;
                            break;
                        }
                    }


                    _tmpSectionReport = new SectionReport(sections[i].SectionName, sections[i].YearLevel, hasweekend);
                    _tmpSectionReport.AddNewPage();
                    _tmpSectionReport.AddLogo(string.Concat(Environment.CurrentDirectory, "/reports/logo.png"));
                    _tmpSectionReport.AddHeaderText_SchoolName("Asian College", "Dumaguete");
                    _tmpSectionReport.AddHeaderText_Department(Program.currentuser_deptDesc);
                    _tmpSectionReport.AddHeaderText_Section(sections[i].SectionName);
                    _tmpSectionReport.Create_ReportTable();

                    for (int y = 0; y < classes.Count; y++)
                    {
                        // concatenate all sections
                        for (int z = 0; z < classes[y].Sections.Count; z++)
                        {
                            if (z == 0)
                            {
                                msections = classes[y].Sections[0].SectionName;
                            }
                            else
                            {
                                msections += string.Concat(", ", classes[y].Sections[z].SectionName);
                            }
                        }

                        GetIndexClassCourse(classes[y]);
                        _tmpSectionReport.AddClass(classes[y], classes[y].Course.Coursecode, classes[y].Room.Name, msections, new MigraDoc.DocumentObjectModel.Color(Program.subjectColors[index_ClassCourse].R, Program.subjectColors[index_ClassCourse].G, Program.subjectColors[index_ClassCourse].B));

                        msections = string.Empty;
                    }

                    acracsReport.Reports_Sections.Add(_tmpSectionReport);
                }

                // Merge all reports & save as pdf file.
                acracsReport.MergeAllReport_Section();
                acracsReport.SaveAllReport_Section(string.Concat(Environment.CurrentDirectory, "/reports/", Program.currentuser_deptId, ".pdf"));
                Program.mainForm.pdfViewer.Document = new Apitron.PDF.Rasterizer.Document(new FileStream(string.Concat(Environment.CurrentDirectory, "/reports/", Program.currentuser_deptId, ".pdf"), FileMode.Open));

                Close();
            }
            catch (Exception ex)
            {
                Program.dbConnection.Close();
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void cmdSelect_Click(object sender, EventArgs e)
        {
            if (cboSections.SelectedItem != null)
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    // Get classes and courses of the section.
                    GetClasses();
                    GetCourses();

                    // determine if classes has saturday or sunday
                    for (int i = 0; i < classes.Count; i++)
                    {
                        if (classes[i].Day == "Saturday" || classes[i].Day == "Sunday")
                        {
                            hasweekend = true;
                            break;
                        }
                    }

                    // Create a new report.
                    report = new SectionReport(sections[cboSections.SelectedIndex].SectionName, sections[cboSections.SelectedIndex].YearLevel, hasweekend);
                    report.AddNewPage();
                    report.AddLogo(string.Concat(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ACRACS-Schedule"), "/reports/logo.png"));
                    report.AddHeaderText_SchoolName("Asian College", "Dumaguete");
                    report.AddHeaderText_Department(Program.currentuser_deptDesc);
                    report.AddHeaderText_Section(sections[cboSections.SelectedIndex].SectionName);
                    report.Create_ReportTable();

                    for (int i = 0; i < classes.Count; i++)
                    {
                        // concatenate all sections
                        for (int x = 0; x < classes[i].Sections.Count; x++)
                        {
                            if (x == 0)
                            {
                                msections = classes[i].Sections[0].SectionName;
                            }
                            else
                            {
                                msections += string.Concat(", ", classes[i].Sections[x].SectionName);
                            }
                        }

                        GetIndexClassCourse(classes[i]);
                        report.AddClass(classes[i], classes[i].Course.Coursecode, classes[i].Room.Name, msections, new MigraDoc.DocumentObjectModel.Color(Program.subjectColors[index_ClassCourse].R, Program.subjectColors[index_ClassCourse].G, Program.subjectColors[index_ClassCourse].B));

                        msections = string.Empty;
                    }
                    report.Render();
                    report.Save(string.Concat(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ACRACS-Schedule", "reports"), "/", sections[cboSections.SelectedIndex].SectionName, ".pdf"));
                    Program.mainForm.pdfViewer.Document = new Apitron.PDF.Rasterizer.Document(new FileStream(string.Concat(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ACRACS-Schedule"), "/reports/", sections[cboSections.SelectedIndex].SectionName, ".pdf"), FileMode.Open));

                    hasweekend = false;
                    Cursor     = Cursors.Default;
                    Close();
                }
                catch (Exception ex)
                {
                    Program.dbConnection.Close();
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Please select a section first.", "No section selected", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }