コード例 #1
0
        private void btnAddToSubject_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <Class> classes = new List <Class>();
                foreach (var selected in this.dataGridClasses.SelectedItems)
                {
                    classes.Add(new Class()
                    {
                        Id = (selected as Class).Id
                    });
                }

                if (classes.Count == 0)
                {
                    MessageBox.Show("Не сте избрали класове");
                }
                else
                {
                    AddToSubjectWindow addToSubjectWindow = new AddToSubjectWindow();
                    if (addToSubjectWindow.ShowDialog() == true)
                    {
                        Subject subject = new Subject()
                        {
                            Id = addToSubjectWindow.SubjectId
                        };
                        client.AddClassesToSubject(subject, classes.ToArray());
                        MessageBox.Show("Класовете бяха добавени към предмета успешно");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.Resources["defaultErrorMessage"].ToString(),
                                "Грешка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }