public void GetLeave() { try { db = new LetranIntegratedSystemEntities(); dl = new List <DisapprovedList>(); var x = db.GetHRiSLeaveCancelled().ToList(); foreach (var i in x) { DisapprovedList Dlist = new DisapprovedList(); Dlist.LeaveID = i.LeaveID; Dlist.EmployeeNo = i.EmployeeNo; Dlist.EmployeeName = i.EmployeeName.ToUpper(); Dlist.DateFiled = i.FiledDate.Value; Dlist.StartDate = i.StartDate.Value; Dlist.EndDate = i.EndDate.Value; Dlist.Type = i.LeaveCode; Dlist.Days = i.Days.Value; Dlist.Status = i.Status; Dlist.Reason = i.Reason; Dlist.LeaveStatusID = i.LeaveApprovedStatusID.Value; dl.Add(Dlist); } dgDisapproved.ItemsSource = dl.OrderByDescending(m => m.DateFiled); } catch (Exception) { MessageBox.Show("Something went wrong!", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning); } }