public void GetHolidays() { try { using (var db = new LetranIntegratedSystemEntities()) { lHRISHoliday = new List <HRISHoliday>(); var holidays = db.HRISHolidays.ToList(); foreach (var x in holidays) { HRISHoliday ho = new HRISHoliday(); ho.Date = x.Date; ho.Description = x.Description; lHRISHoliday.Add(ho); } dgHolidaysList.ItemsSource = lHRISHoliday.OrderBy(m => m.Date); } } catch (Exception) { throw; } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { using (var db = new LetranIntegratedSystemEntities()) { HRISHoliday ho = new HRISHoliday(); ho.Date = hodate.SelectedDate.Value; ho.Description = txtDescription.Text; db.HRISHolidays.Add(ho); db.SaveChanges(); MessageBox.Show("Successfully added.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information); clear(); } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }