public void GridRefresh() { try { db = new LetranIntegratedSystemEntities(); EDList = new List <EmployeeDepartmentList>(); var emp = db.GetHRiSEmployeebyDepartment().ToList(); foreach (var x in emp) { EmployeeDepartmentList edl = new EmployeeDepartmentList(); edl.Department = x.AcaDepartmentName; edl.EmployeeDesignation = x.EmployeeStatusName; edl.EmployeeLevel = x.EmployeeLevel; edl.EmployeeName = x.EmployeeName.ToUpper(); edl.EmployeePosition = x.EmployeePositionName; EDList.Add(edl); } EDList = EDList.OrderBy(m => m.Department).ToList(); ListCollectionView edlcollection = new ListCollectionView(EDList); edlcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department")); dgEmployeeDepartment.ItemsSource = edlcollection; } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnLoad_Click(object sender, RoutedEventArgs e) { try { Mouse.OverrideCursor = Cursors.Wait; db = new LetranIntegratedSystemEntities(); EDList = new List <EmployeeDepartmentList>(); var dept = cbDepartment.SelectedValue.ToString(); var emp = db.GetHRiSEmployeebyDepartment().ToList(); foreach (var x in emp) { EmployeeDepartmentList edl = new EmployeeDepartmentList(); edl.Department = x.AcaDepartmentName; edl.EmployeeDesignation = x.EmployeeStatusName; edl.EmployeeLevel = x.EmployeeLevel; edl.EmployeeName = x.EmployeeName; edl.EmployeePosition = x.EmployeePositionName; EDList.Add(edl); } EDList = EDList.OrderBy(m => m.Department).Where(m => m.Department == dept).ToList(); ListCollectionView edlcollection = new ListCollectionView(EDList); edlcollection.GroupDescriptions.Add(new PropertyGroupDescription("Department")); dgEmployeeDepartment.ItemsSource = edlcollection; Mouse.OverrideCursor = null; } catch (Exception) { Mouse.OverrideCursor = null; MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }