private void cbMonth_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { EBList = new List <BirthdayList>(); using (var db = new LetranIntegratedSystemEntities()) { if (cbMonth.SelectedItem != null) { int xmonth = Convert.ToInt32(cbMonth.SelectedValue) + 1; var getbday = db.GetHRiSBirthdayCelebrants(xmonth).OrderByDescending(m => m.Day).ToList(); foreach (var x in getbday) { BirthdayList eb = new BirthdayList(); eb.EmployeeName = x.EmployeeName.ToUpper(); eb.Department = x.Department; eb.Day = x.Day.Value; if (x.Day.Value == DateTime.Now.Day) { eb.IsToday = true; } else { eb.IsToday = false; } eb.Month = cbMonth.Text; EBList.Add(eb); } dgBirthday.ItemsSource = EBList; } else { MessageBox.Show("Select an item.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }