Example #1
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;
        }
Example #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");
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            OlympType newType = new OlympType();

            newType.Name = Name_;

            GetPropForSelectedService GettingService = new GetPropForSelectedService();

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

            AddingService service = new AddingService();

            service.AddOlympType(newType);

            MessageBox.Show("New olymp type added.");
        }