コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitMedalStandings()
        {
            List <MedalStandings>     MedalsStanding = new List <MedalStandings>();
            GetPropForSelectedService service        = new GetPropForSelectedService();

            List <string> bufCountries = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.Person.Country.Name).Select(g => g.Key).ToList();
            var           OlympRes     = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date);

            if (OlympRes == null)
            {
                return;
            }

            for (int i = 0; i < bufCountries.Count; i++)
            {
                MedalStandings bufMedal = new MedalStandings();

                bufMedal.Country = bufCountries[i];
                bufMedal.Golds   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 1).Count();
                bufMedal.Sereb   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 2).Count();;
                bufMedal.Bronz   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 3).Count();
                bufMedal.All     = bufMedal.Golds + bufMedal.Sereb + bufMedal.Bronz;

                MedalsStanding.Add(bufMedal);
            }
            MedalsStanding.OrderBy(x => x.All);
            MedalStandingsListBox.ItemsSource = MedalsStanding.OrderByDescending(x => x.All);

            for (int i = 0; i < MedalStandingsListBox.Items.Count; i++)
            {
                (MedalStandingsListBox.Items[i] as MedalStandings).Number = i + 1;
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void OlympiadTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            DateTime currOlympDate = new DateTime();

            foreach (var o in service.GetOlympiads())
            {
                string bufName;
                string gettingOlympName;

                bufName          = ((sender as TreeView).SelectedItem as TreeViewItem).Header.ToString();
                gettingOlympName = $"{o.Type.Name} olympiad in {o.Country.Name} {String.Format("{0:y}", o.Date)}";

                if (bufName == gettingOlympName)
                {
                    currOlympDate = o.Date;
                }
            }

            if (CurrentOlympaid != null)
            {
                if (CurrentOlympaid.Date == currOlympDate)
                {
                    return;
                }
            }

            CurrentOlympaid = service.GetOlympiads().FirstOrDefault(x => x.Date == currOlympDate);

            MainStackPanel.Visibility = Visibility.Visible;
            InitContentUI();
        }
コード例 #3
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            if (DatePicker.DisplayDate == null)
            {
                MessageBox.Show("Date can`t be null.");
                return;
            }

            Olympiad newType = new Olympiad();

            GetPropForSelectedService getService = new GetPropForSelectedService();

            newType.Date    = DatePicker.SelectedDate.Value;
            newType.Type    = getService.GetOlympTypes().FirstOrDefault(x => x.Name == (OlympTypeComboBox.SelectedItem as OlympType).Name);
            newType.Country = getService.GetCountry().FirstOrDefault(x => x.Name == (CountryComboBox.SelectedValue as Country).Name);


            foreach (var o in getService.GetOlympiads())
            {
                if (o.Date == newType.Date)
                {
                    MessageBox.Show($"Olympiads in {o.Date.ToString("0:d")} alredy exists.");
                }
            }

            AddingService addService = new AddingService();

            addService.AddOlympiad(newType);
            MessageBox.Show("Olympiad adding");
        }
コード例 #4
0
        private void OlympiadComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GetPropForSelectedService getService = new GetPropForSelectedService();

            PersonComboBox.ItemsSource = getService.GetPersons()
                                         .Where(x => x.Country.Name == (OlympiadComboBox.SelectedValue as Olympiad).Country.Name);
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void LoadSportsMedalists(string Sport)
        {
            GetPropForSelectedService service      = new GetPropForSelectedService();
            List <SportMedal>         sportsMedals = new List <SportMedal>();

            var Res = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date && x.SportType.Name == Sport && x.Place == 1).Select(x => x.Person).ToList();

            if (Res == null)
            {
                return;
            }

            foreach (var p in Res)
            {
                SportMedal sportMedal = new SportMedal();

                sportMedal.Country = p.Country.Name;
                sportMedal.AllName = $"{p.FirstName} {p.SecondName} {p.ThirdName}";

                sportsMedals.Add(sportMedal);
            }


            StatStore_SportsMedalistListBox.ItemsSource = sportsMedals.OrderByDescending(x => x.Country);

            for (int i = 0; i < StatStore_SportsMedalistListBox.Items.Count; i++)
            {
                (StatStore_SportsMedalistListBox.Items[i] as SportMedal).Number = i + 1;
            }
        }
コード例 #6
0
        public AddOlympiadWindow()
        {
            InitializeComponent();

            GetPropForSelectedService service = new GetPropForSelectedService();

            Countries  = service.GetCountry(false);
            OlympTypes = service.GetOlympTypes(false);

            if (Countries.Count <= 0)
            {
                this.Hide();
                MessageBox.Show("Add countries first.");
                this.Close();
                return;
            }
            if (OlympTypes.Count <= 0)
            {
                this.Hide();
                MessageBox.Show("Add olymp types first.");
                this.Close();
                return;
            }

            OlympTypeComboBox.ItemsSource = OlympTypes;
            CountryComboBox.ItemsSource   = Countries;

            this.DataContext = this;
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void LoadOlympaidTeamStats(string Team)
        {
            GetPropForSelectedService service   = new GetPropForSelectedService();
            List <TeamStat>           TeamStats = new List <TeamStat>();

            var Res = service.GetOlympsResult()
                      .Where(x => x.Person.Country.Name == Team)
                      .Select(x => new { x.Person, x.Place }).ToList();

            List <string> SportTypes = service.GetOlympsResult().GroupBy(x => x.SportType).Select(x => x.Key.Name).ToList();

            if (Res == null)
            {
                return;
            }

            for (int i = 0; i < Res.Count; i++)
            {
                TeamStat teamStat = new TeamStat();


                teamStat.Sport   = SportTypes[i];
                teamStat.AllName = $"{Res[i].Person.FirstName}" +
                                   $" {Res[i].Person.SecondName} " +
                                   $"{Res[i].Person.ThirdName}";
                teamStat.Place = Res[i].Place;

                TeamStats.Add(teamStat);
            }

            //foreach (var s in Res)
            //{
            //    TeamStat teamStat = new TeamStat();


            //    teamStat.Sport = s.SportType.Name;
            //    teamStat.AllName = $"{s.Person.FirstName}" +
            //        $" {s.Person.SecondName} " +
            //        $"{s.Person.ThirdName}";
            //    teamStat.Place = s.Place;

            //    TeamStats.Add(teamStat);
            //}

            if (TeamStats == null)
            {
                return;
            }

            StatStore_TeamStatsListBox.ItemsSource = TeamStats.OrderByDescending(x => x.Place);

            for (int i = 0; i < StatStore_TeamStatsListBox.Items.Count; i++)
            {
                (StatStore_TeamStatsListBox.Items[i] as TeamStat).Number = i + 1;
            }
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitOlympList()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            foreach (var o in service.GetOlympiads().OrderByDescending(x => x.Date))
            {
                TreeViewItem Item = new TreeViewItem();

                Item.Header = $"{o.Type.Name} olympiad in {o.Country.Name} {String.Format("{0:y}", o.Date)}";

                OlympiadTreeView.Items.Add(Item);
            }
        }
コード例 #9
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitAthleteRecord()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            var bufSports = service.GetOlympsResult().GroupBy(x => x.SportType.Name).Select(x => x.Key).ToList();

            try
            {
                StatStore_RecodHolderComboBOx.ItemsSource  = bufSports;
                StatStore_RecodHolderComboBOx.SelectedItem = bufSports[0];
            }
            catch (Exception)
            {
            }
        }
コード例 #10
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitTeamStats()
        {
            GetPropForSelectedService service      = new GetPropForSelectedService();
            List <string>             bufCountries = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.Person.Country.Name).Select(g => g.Key).ToList();

            try
            {
                StatStore_TeamStatsCountryComboBox.ItemsSource  = bufCountries;
                StatStore_TeamStatsCountryComboBox.SelectedItem = StatStore_TeamStatsCountryComboBox.Items[0];
            }
            catch (Exception)
            {
            }
        }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitCompositionOfOlympTeam()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            List <string> countries = service.GetOlympsResult().GroupBy(x => x.Person.Country.Name).Select(x => x.Key).OrderByDescending(x => x.Count()).ToList();

            try
            {
                StatStore_CompositionOfOlympTeamComboBox.ItemsSource  = countries;
                StatStore_CompositionOfOlympTeamComboBox.SelectedItem = countries[0];
            }
            catch (Exception)
            {
            }
        }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitSportsMedalists()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            List <string> sports = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.SportType.Name).Select(x => x.Key).ToList();

            try
            {
                StatStore_SportsMedalistComboBox.ItemsSource  = sports;
                StatStore_SportsMedalistComboBox.SelectedItem = StatStore_SportsMedalistComboBox.Items[0];
            }
            catch (Exception)
            {
            }
        }
コード例 #13
0
        public AddCityWindow()
        {
            InitializeComponent();

            GetPropForSelectedService getService = new GetPropForSelectedService();

            if (getService.GetCountry(true).Count <= 0)
            {
                MessageBox.Show("Add country first.");
                this.Close();
                return;
            }

            CountryComboBox.ItemsSource = getService.GetCountry(false);

            this.DataContext = this;
        }
コード例 #14
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            OlympResult newType = new OlympResult();
            GetPropForSelectedService getService = new GetPropForSelectedService();


            newType.OlympID     = getService.GetOlympiads().FirstOrDefault(x => x.Date == (OlympiadComboBox.SelectedItem as Olympiad).Date).ID;
            newType.SportTypeID = getService.GetSportTypes().FirstOrDefault(x => x.Name == (OlympiadComboBox.SelectedItem as SportType).Name).ID;

            newType.PersonID = getService.GetPersons().FirstOrDefault(x => x.FirstName == (OlympiadComboBox.SelectedItem as Person).FirstName &&
                                                                      x.SecondName == (OlympiadComboBox.SelectedItem as Person).SecondName &&
                                                                      x.ThirdName == (OlympiadComboBox.SelectedItem as Person).ThirdName).ID;

            newType.Place = Convert.ToInt32(PlaceTextBox.Text);


            foreach (var or in getService.GetOlympsResult())
            {
                if (or.Olympiad.Date == newType.Olympiad.Date)
                {
                    if (or.SportType.Name == newType.SportType.Name)
                    {
                        //if(or.City.Name == newType.City.Name)
                        if (or.Person.FirstName == newType.Person.FirstName)
                        {
                            if (or.Person.SecondName == newType.Person.SecondName)
                            {
                                if (or.Person.ThirdName == newType.Person.ThirdName)
                                {
                                    if (or.Place == newType.Place)
                                    {
                                        MessageBox.Show("This node alredy exist.");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            AddingService addService = new AddingService();

            addService.AddOlympiadResultNode(newType);
            MessageBox.Show("New result node adding.");
        }
コード例 #15
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void LoadAthleteRecordHolder(string Sport)
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            Person Res = service.GetOlympsResult().Where(x => x.SportType.Name == Sport && x.Place == 1).Select(x => x.Person).First();

            string Holder;

            if (Res == null)
            {
                Holder = "None";
                StatStore_RecodHolderTextBlock.Text = Holder;
                return;
            }

            Holder = $"{Res.FirstName} {Res.SecondName} {Res.ThirdName}";
            StatStore_RecodHolderTextBlock.Text = Holder;
        }
コード例 #16
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void LoadCompositionOfOlympTeam(string Team)
        {
            GetPropForSelectedService service   = new GetPropForSelectedService();
            List <TeamStat>           TeamStats = new List <TeamStat>();

            var Res = service.GetOlympsResult().Where(x => x.Person.Country.Name == Team).GroupBy(x => new
            {
                x.Person,
                x.Person.Country,
                x.SportType
            }).ToList();

            CompositionOfOlympTeamWindow window =
                new CompositionOfOlympTeamWindow(Team, Res.Select(x => x.Key.Person).ToList(), Res.Select(x => x.Key.SportType).ToList());

            window.ShowDialog();
        }
コード例 #17
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            if (DatePicker.DisplayDate == null)
            {
                MessageBox.Show("Date can`t be null.");
                return;
            }
            if (PhotoPath == null)
            {
                MessageBox.Show("Photo can`t be null.");
                return;
            }


            Person newType = new Person();
            GetPropForSelectedService getService = new GetPropForSelectedService();

            newType.FirstName   = FirstName;
            newType.SecondName  = SecondName;
            newType.ThirdName   = ThirdName;
            newType.CountryID   = getService.GetCountry(false).FirstOrDefault(x => x.Name == (CountryComboBox.SelectedItem as Country).Name).ID;
            newType.DateOfBirth = DatePicker.SelectedDate.Value;
            newType.PhotoPath   = PhotoPath;


            foreach (var p in getService.GetPersons())
            {
                if (p.FirstName == newType.FirstName)
                {
                    if (p.SecondName == newType.SecondName)
                    {
                        if (p.ThirdName == newType.ThirdName)
                        {
                            MessageBox.Show($"{p.FirstName} {p.SecondName} {p.ThirdName} alredy exist`s.");
                            return;
                        }
                    }
                }
            }


            AddingService addService = new AddingService();

            addService.AddPerson(newType);
            MessageBox.Show("New person added.");
        }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: Bandera1/Olympiad
        private void InitHostestOfOlymps()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            //var count = service.GetOlympsResult().GroupBy(x => x.Person.Country).Select(group => new
            //{
            //    Name = group.Key,
            //    Count = group.Count()
            //}).OrderByDescending(x => x.Count).Select(x => x.Count).ToList();

            //var count = service.GetOlympsResult().GroupBy(x => x.Person.Country).Select(group => new
            //{
            //    Count = group.Count()
            //}).Select(x => x.Count);

            var country = service.GetOlympsResult().GroupBy(x => x.Person.Country.Name).OrderByDescending(x => x.Count()).First();

            StatStore_ThemeMostHostTextBlock.Text = country.Key;
        }
コード例 #19
0
        public AddOlympResultNode()
        {
            InitializeComponent();

            GetPropForSelectedService getService = new GetPropForSelectedService();

            Olympiads  = RemakeOlymp(getService.GetOlympiads());
            SportTypes = getService.GetSportTypes();
            //Cities = getService.GetCities();
            Persons = getService.GetPersons();

            DataCheck();

            OlympiadComboBox.ItemsSource  = Olympiads;
            SportTypeComboBox.ItemsSource = SportTypes;
            PersonComboBox.ItemsSource    = Persons;

            this.DataContext = this;
        }
コード例 #20
0
        public AddPersonWindow()
        {
            InitializeComponent();


            GetPropForSelectedService service = new GetPropForSelectedService();

            Countries = service.GetCountry(true);

            if (Countries.Count <= 0)
            {
                this.Hide();
                MessageBox.Show("Add countries first.");
                this.Close();
                return;
            }

            CountryComboBox.ItemsSource = Countries;

            this.DataContext = this;
        }
コード例 #21
0
        private void OlympResultInit()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            var Results = service.GetOlympsResult();

            List <OlympResultNodeTemplate> ResultsData = new List <OlympResultNodeTemplate>();

            foreach (var r in Results)
            {
                OlympResultNodeTemplate node = new OlympResultNodeTemplate();

                node.OlympiadName  = $"{r.Olympiad.Type.Name} olympiad in {r.Olympiad.Country.Name} {String.Format("{0:y}", r.Olympiad.Date)}";
                node.PersonName    = $"{r.Person.FirstName} {r.Person.SecondName} {r.Person.ThirdName}";
                node.SportTypeName = r.SportType.Name;
                node.Place         = r.Place;

                ResultsData.Add(node);
            }

            OlympResultDataGrid.ItemsSource = ResultsData;
        }
コード例 #22
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            Country newType = new Country();

            newType.Name = Name_;

            GetPropForSelectedService GettingService = new GetPropForSelectedService();

            foreach (var type in GettingService.GetCountry())
            {
                if (type.Name == Name_)
                {
                    MessageBox.Show($"{Name_} alredy exists.");
                    return;
                }
            }

            AddingService service = new AddingService();

            service.AddCountry(newType);

            MessageBox.Show("New country added.");
        }
コード例 #23
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SportType newType = new SportType();

            newType.Name = Name_;

            GetPropForSelectedService GettingService = new GetPropForSelectedService();

            foreach (var type in GettingService.GetSportTypes())
            {
                if (type.Name == Name_)
                {
                    MessageBox.Show($"{Name_} type alredy exists.");
                    return;
                }
            }

            AddingService service = new AddingService();

            service.AddSportType(newType);

            MessageBox.Show("New sport type added.");
        }
コード例 #24
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            City newType = new City();

            newType.Name    = Name_;
            newType.Country = (CountryComboBox.SelectedItem as Country);

            GetPropForSelectedService GettingService = new GetPropForSelectedService();

            foreach (var type in GettingService.GetCities())
            {
                if (type.Name == Name_)
                {
                    MessageBox.Show($"{Name_} type alredy exists.");
                    return;
                }
            }

            AddingService service = new AddingService();

            service.AddCity(newType);

            MessageBox.Show("New city added.");
        }