Esempio n. 1
0
        private void AddNewStandard()
        {
            SchoolObjContext context = new SchoolObjContext();

            if (NameToBeAdded != null && NameToBeAdded != " " && NameToBeAdded != "")
            {
                EntityDatabase.DomainClasses.Standard std = new EntityDatabase.DomainClasses.Standard()
                {
                    StandardName = NameToBeAdded
                };
                context.Standards.Add(std);
                context.SaveChanges();
                StandardList.Add(context.Standards.AsEnumerable().Last());
                var StdId = context.Standards.Where(s => s.StandardName == NameToBeAdded).FirstOrDefault().StandardId;

                NameToBeAdded = "";

                MainViewModel.RefreshView("Subjects");
                MainViewModel.RefreshView("Show Students");
                MainViewModel.RefreshView("Result Report");


                MainViewModel.Tabs.Add(new SubjectViewModel(StdId));
            }
        }
 private void StandardSelectionChanged(EntityDatabase.DomainClasses.Standard std)
 {
     using (SchoolObjContext Context = new SchoolObjContext())
     {
         if (AllSubjects != null)
         {
             AllSubjects = null;
         }
         if (std == null || std.StandardId == 0)
         {
             AllSubjects = new ObservableCollection <object>(
                 (from Subject in Context.Subjects
                  join Standard in Context.Standards
                  on Subject.StandardId equals Standard.StandardId
                  select new
             {
                 Id = Subject.Id,
                 Name = Subject.Name,
                 Standard = Standard.StandardName
             }).ToList()
                 );
             StdColumnVisibility = System.Windows.Visibility.Visible;
         }
         else
         {
             AllSubjects         = new ObservableCollection <object>(Context.Subjects.Where(s => s.StandardId == std.StandardId).ToList());
             StdColumnVisibility = System.Windows.Visibility.Hidden;
         }
     }
 }