private void LoadReport() { DateTime dtStartDate = DateTime.Now; DateTime dtEndDate = DateTime.Now; switch (CurrentlySelectedDatePeriod) { case DateTypeSelection.CurrentlMonthOnly: dtStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); dtEndDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); break; case DateTypeSelection.CustomDatePeriod: //58,c5,cb,25,40,91 dtStartDate = metroDateTime1.Value.Date; dtEndDate = metroDateTime2.Value.Date; break; } List <GetStudentRegister_Result> ds = new List <GetStudentRegister_Result>(); switch (CurrentlySelectedConfirmationType) { case ConfrimationSelection.SelectAll: using (var Dbconnection = new MCDEntities()) { ds = Dbconnection.GetStudentRegister(dtStartDate, dtEndDate).ToList <GetStudentRegister_Result>(); }; break; case ConfrimationSelection.SelectOnlyConfirmed: using (var Dbconnection = new MCDEntities()) { ds = Dbconnection.GetStudentRegister(dtStartDate, dtEndDate).Where(a => a.Confirmed == "Y").ToList <GetStudentRegister_Result>(); }; break; case ConfrimationSelection.SeletOnlyNotYetCopnfirmed: using (var Dbconnection = new MCDEntities()) { ds = Dbconnection.GetStudentRegister(dtStartDate, dtEndDate).Where(a => a.Confirmed == "N").ToList <GetStudentRegister_Result>(); }; break; } ScheduleStudentRegister rpt = new ScheduleStudentRegister(); List <StudentRegister> x = new List <StudentRegister>(); //ds.ForEach(GetAllEnrollmentsCompanyAndStudent_Result GAECASR in ) foreach (GetStudentRegister_Result GSR in ds) { x.Add(new StudentRegister() { Company = GSR.Company, Confirmed = GSR.Confirmed, CostCode = GSR.CostCode, Course = GSR.Course, Department = GSR.Department, Duration = GSR.Duration, EndDate = GSR.EndDate, IDNumber = GSR.IDNumber, StartDate = GSR.StartDate, StudentName = GSR.StudentName, CurriculumName = GSR.CurriculumName }); } rpt.SetDataSource(x); crystalReportViewer1.ReportSource = rpt; crystalReportViewer1.RefreshReport(); }