TeamDetail.xaml.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using NBAManagment.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace NBAManagment
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для TeamDetail.xaml
  20. /// </summary>
  21. public partial class TeamDetail : Window
  22. {
  23. private Team selectteam;
  24. public static PracticeNBAEntities DataEntitiesEmployee { get; set; }
  25. public static ObservableCollection<PlayerInTeam> ListEmployee;
  26. public static PracticeNBAEntities DataEntitiesEmploye1 { get; set; }
  27. public static ObservableCollection<MatchupDetail> ListEmployee1;
  28. public TeamDetail(Team selectteam = null)
  29. {
  30. if (selectteam != null)
  31. {
  32. this.selectteam = selectteam;
  33. }
  34. DataEntitiesEmployee = new PracticeNBAEntities();
  35. DataEntitiesEmploye1 = new PracticeNBAEntities();
  36. InitializeComponent();
  37. ListEmployee = new ObservableCollection<PlayerInTeam>();
  38. ListEmployee1 = new ObservableCollection<MatchupDetail>();
  39. }
  40. private void Page_Loaded(object sender, RoutedEventArgs e)
  41. {
  42. if (selectteam != null)
  43. {
  44. foreach (PlayerInTeam emp in selectteam.PlayerInTeam)
  45. {
  46. ListEmployee.Add(emp);
  47. }
  48. DataGridEmployee.ItemsSource = ListEmployee;
  49. }
  50. else
  51. {
  52. var querryEmployee = DataEntitiesEmployee.PlayerInTeam.OrderBy(Employee => Employee.IdPlayerInTeam);
  53. foreach (PlayerInTeam emp in querryEmployee)
  54. {
  55. ListEmployee.Add(emp);
  56. }
  57. DataGridEmployee.ItemsSource = ListEmployee;
  58. }
  59. var querryEmployee1 = DataEntitiesEmployee.MatchupDetail.OrderBy(Employee => Employee.IdMatchupDetail);
  60. foreach (MatchupDetail emp1 in querryEmployee1)
  61. {
  62. ListEmployee1.Add(emp1);
  63. }
  64. DataGridEmployee1.ItemsSource = ListEmployee1;
  65. }
  66. }
  67. }