示例#1
0
        public VMGroups()
        {
            entities = DB.GetDB();
            LoadGroups();
            Groups   = new ObservableCollection <Group>(entities.Groups);
            Specials = new ObservableCollection <Special>(entities.Specials);

            AddGroup = new CustomCommand(() =>
            {
                var group = new Group {
                    Number = "Номер группы"
                };
                entities.Groups.Add(group);
                SelectedGroup = group;
            });

            SaveGroups = new CustomCommand(() =>
            {
                try
                {
                    entities.SaveChanges();
                    LoadGroups();
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message);
                }
            });

            OpenSpecials = new CustomCommand(() => { CurrentPage = new WinSpecials(); SignalChanged("CurrentPage"); });
            OpenGroups   = new CustomCommand(() => { CurrentPage = new WinGroups(); SignalChanged("CurrentPage"); });
        }
示例#2
0
 public static Entities2 GetDB()
 {
     if (Entities2 == null)
     {
         Entities2 = new Entities2();
     }
     return(Entities2);
 }
示例#3
0
 public MainVM()
 {
     entities     = DB.GetDB();
     Specials     = new ObservableCollection <Special>(entities.Specials);
     OpenSpecials = new CustomCommand(() => { CurrentPage = new WinSpecials(); SignalChanged("CurrentPage"); });
     OpenGroups   = new CustomCommand(() => { CurrentPage = new WinGroups(); SignalChanged("CurrentPage"); });
     OpenStudents = new CustomCommand(() => { CurrentPage = new WinSudents(); SignalChanged("CurrentPage"); });
     OpenList     = new CustomCommand(() => { CurrentPage = new MainPage(); SignalChanged("CurrentPage"); });
 }