/// <summary>
        /// Populates StudentYearCollection with all StudentYearDescription in the StudentYear table
        /// in the database
        /// </summary>
        /// <returns></returns>
        public void PopulateStudentYears()
        {
            try
            {
                using (var context = new SchoolU_DBEntities())
                {
                    context.Database.Connection.Open();
                    StudentYearCollection.Clear();
                    StudentYearCollection.Add(new StudentYear {
                        StudentYearDescription = "None"
                    });
                    var dbStudentYears = context.StudentYears.Where(i => i.StudentYearId != 0).ToList();

                    foreach (var m in dbStudentYears)
                    {
                        StudentYearCollection.Add(new StudentYear {
                            StudentYearDescription = m.StudentYearDescription
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets all comboboxes to their default value
 /// </summary>
 public void ClearFilters()
 {
     SelectedFirstName   = StudentCollection.Where(i => i.StudentFirstName == "None").Single();
     SelectedLastName    = StudentCollection.Where(i => i.StudentLastName == "None").Single();
     SelectedMajor       = MajorCollection.Where(i => i.MajorDescription == "None").Single();
     SelectedStudentYear = StudentYearCollection.Where(i => i.StudentYearDescription == "None").Single();
     AllStudentInformation.Clear();
     PopulateResultView_NoFilters();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Enables/Disables "Clear Filters" button
 /// </summary>
 /// <returns></returns>
 public bool IsClearable()
 {
     return(IsClearEnabled = ((SelectedFirstName != null && SelectedFirstName.StudentFirstName != StudentCollection.Where(i => i.StudentFirstName == "None").Select(i => i.StudentFirstName).Single()) ||
                              (SelectedLastName != null && SelectedLastName.StudentFirstName != StudentCollection.Where(i => i.StudentLastName == "None").Select(i => i.StudentLastName).Single()) ||
                              (SelectedMajor != null && SelectedMajor.MajorDescription != MajorCollection.Where(i => i.MajorDescription == "None").Select(i => i.MajorDescription).Single()) ||
                              (SelectedStudentYear != null && SelectedStudentYear.StudentYearDescription != StudentYearCollection.Where(i => i.StudentYearDescription == "None").Select(i => i.StudentYearDescription).Single())));
 }