Beispiel #1
0
 /// <summary>
 /// Initializes the Buffer Class
 /// </summary>
 public static void Initialize()
 {
     _utDisposed          = false;
     _ptDisposed          = false;
     _rqDisposed          = false;
     _userTable           = new UsersTableAdapter();
     _pkmnTable           = new PokemonTableAdapter();
     _requTable           = new RequirementsTableAdapter();
     _userTable.Disposed += (sender, args) => _utDisposed = true;
     _pkmnTable.Disposed += (sender, args) => _ptDisposed = true;
     _requTable.Disposed += (sender, args) => _rqDisposed = true;
 }
        public ActionResult Report(string ReportType, string ListOfStudents, string CurrentFormer, string FromDateParam, string ToDateParam)
        {
            DataSet1 ds = new DataSet1();

            ReportParameter[] paramsArray;

            ReportViewer reportViewer = new ReportViewer();

            reportViewer.ProcessingMode      = ProcessingMode.Local;
            reportViewer.SizeToReportContent = true;
            reportViewer.Width  = Unit.Percentage(100);
            reportViewer.Height = Unit.Percentage(100);

            switch (ReportType)
            {
            case "Background":

                paramsArray    = new ReportParameter[4];
                paramsArray[0] = new ReportParameter("FromDateParam", FromDateParam.ToString());
                paramsArray[1] = new ReportParameter("ToDateParam", ToDateParam.ToString());
                paramsArray[2] = new ReportParameter("Student", ListOfStudents.ToString());
                paramsArray[3] = new ReportParameter("CurrentFormer", CurrentFormer.ToString());


                BackgroundTableAdapter bta = new BackgroundTableAdapter();
                bta.Fill(ds.Background, FromDateParam, ToDateParam, ListOfStudents, CurrentFormer);

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Rpt1-Background.rdlc";
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Background", ds.Tables[0]));

                reportViewer.LocalReport.SetParameters(paramsArray);

                reportViewer.LocalReport.Refresh();

                break;

            case "Coursework":

                paramsArray    = new ReportParameter[1];
                paramsArray[0] = new ReportParameter("Student", ListOfStudents.ToString());


                CourseworkTableAdapter cta = new CourseworkTableAdapter();
                cta.Fill(ds.Coursework, ListOfStudents);

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Rpt2-Coursework.rdlc";
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Coursework", ds.Tables[1]));

                reportViewer.LocalReport.SetParameters(paramsArray);

                reportViewer.LocalReport.Refresh();

                break;

            case "Performance":

                paramsArray    = new ReportParameter[1];
                paramsArray[0] = new ReportParameter("Student", ListOfStudents.ToString());


                PerformanceTableAdapter pta = new PerformanceTableAdapter();
                pta.Fill(ds.Performance, ListOfStudents);

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Rpt3-Performance.rdlc";
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Performance", ds.Tables[2]));

                reportViewer.LocalReport.SetParameters(paramsArray);

                reportViewer.LocalReport.Refresh();

                break;

            case "Requirements":

                paramsArray    = new ReportParameter[4];
                paramsArray[0] = new ReportParameter("Student", ListOfStudents.ToString());
                paramsArray[1] = new ReportParameter("CurrentFormer", CurrentFormer.ToString());
                paramsArray[2] = new ReportParameter("FromDateParam", FromDateParam.ToString());
                paramsArray[3] = new ReportParameter("ToDateParam", ToDateParam.ToString());


                RequirementsTableAdapter rta = new RequirementsTableAdapter();
                rta.Fill(ds.Requirements, FromDateParam, ToDateParam, ListOfStudents, CurrentFormer);

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Rpt4-Requirements.rdlc";
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Requirements", ds.Tables[3]));

                reportViewer.LocalReport.SetParameters(paramsArray);

                reportViewer.LocalReport.Refresh();

                break;

            case "PostGraduation":

                paramsArray    = new ReportParameter[1];
                paramsArray[0] = new ReportParameter("Student", ListOfStudents.ToString());

                PostgraduationTableAdapter pgta = new PostgraduationTableAdapter();
                pgta.Fill(ds.Postgraduation, ListOfStudents);

                reportViewer.LocalReport.DataSources.Clear();

                reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Rpt5-Postgraduation.rdlc";
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Postgraduation", ds.Tables[4]));

                reportViewer.LocalReport.SetParameters(paramsArray);

                reportViewer.LocalReport.Refresh();

                break;

            default:
                break;
            }

            var students =
                db.Students.AsEnumerable().Select(s => new
            {
                //ID = s.Id,
                FullName = string.Format("{0} {1}", s.FirstName, s.LastName)
            }).OrderBy(s => s.FullName).ToList();

            ViewBag.ListOfStudents = new SelectList(students, "FullName", "FullName");

            ViewBag.ReportViewer = reportViewer;

            return(View());
        }