コード例 #1
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();
        }
コード例 #2
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");
        }
コード例 #3
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);
            }
        }
コード例 #4
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.");
        }
コード例 #5
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;
        }