示例#1
0
        private void GroupAddButtonClick(object sender, RoutedEventArgs e)
        {
            var db = (Application.Current as App).db;

            Model.Group g = new Model.Group
            {
                Number = 1,
                Course = 1,
                Track  = "POKS"
            };
            db.Groups.Add(g);
            (this.Resources["groupViewSource"] as CollectionViewSource).View.Refresh();
        }
示例#2
0
        private void RemoveGroupButton_Click(object sender, RoutedEventArgs e)
        {
            var db = (Application.Current as App).db;

            Model.Group group = groupsListBox.SelectedItem as Model.Group;
            if (group != null)
            {
                var studentViewSource  = ((CollectionViewSource)(this.FindResource("studentViewSource")));
                var studentsCollection = studentViewSource.Source as ObservableCollection <Model.Student>;

                foreach (Model.Student s in studentsCollection.ToArray <Model.Student>())
                {
                    if (s.GroupId == group.Id)
                    {
                        db.Students.Remove(s);
                    }
                }
                db.Groups.Remove(group);
                (this.Resources["groupViewSource"] as CollectionViewSource).View.Refresh();
            }
        }