示例#1
0
        private void OnLogin(object sender, System.EventArgs e)
        {
            Title = "Highlands School";
            loginOverlay.Visibility = System.Windows.Visibility.Hidden;
            _gradebook = studentsControl.LoadGradebook();
            ctrlClasses.Refresh(_gradebook);
            ctrlAttendees.Refresh();
            //ctrlClasses.Visibility = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanEditAttendance);
            //tabAttendance.Visibility = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanEditAttendance);
            tabClasses.Visibility   = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanViewGrades);
            tabStudents.Visibility  = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanViewGrades);
            btnExport.Visibility    = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanImportExport);
            btnImport.Visibility    = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanImportExport);
            btnHonorRoll.Visibility = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanViewHonorRoll);
            tabClasses.Visibility   = ViewUtils.IsVisible(UserViewModel.CurrentUser.HasStudents);

            staUser.Content = "Welcome, " + UserViewModel.CurrentUser;
        }
        private Grades FillGrades()
        {
            var rv = new Grades();

            btnSaveReportCards.Visibility = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanExportReportCards);
            var courses = _gradebook.Courses;

            courses = courses.Where(c => c.Teacher == UserViewModel.CurrentUser.Name);
            courses = courses.Where(c => c.Quarter == MarkingPeriodKey.Current.ToString());

            foreach (var course in courses)
            {
                //grd.Items.Add(course);
                foreach (var grade in course.Grades)
                {
                    rv.Add(new StudentByClass(grade));
                    //rv.Add(new dv() { Grade = grade.LetterGrade, Name = grade.StudentName, Stage = grade.ApprovalStage.ToString() });
                }
            }
            return(rv);
        }
        public void LoadStudent(StudentViewModel student)
        {
            _student = student;

            nameHeader.Text             = student.Name;
            noStudentOverlay.Visibility = System.Windows.Visibility.Hidden;
            var currentUser = UserViewModel.CurrentUser;

            chkMyClasses.IsChecked    = currentUser.HasStudents;
            chkMyClasses.IsEnabled    = currentUser.HasStudents;
            gridStudentInfo.IsEnabled = currentUser.CanEditStudentInfo;

            _sdScores = new ObservableCollection <SDScoreViewModel>();
            _grades   = new ObservableCollection <GradeViewModel>();
            RefreshMarks();

            entName.Text             = _student.Name;
            dtpDob.SelectedDate      = _student.DOB;
            entAddress.Text          = _student.AddressLine1 + "," + student.AddressLine2;
            dtpEnrolled.SelectedDate = _student.DateEnrolled;
            if (_student.DateWithdrawn.HasValue)
            {
                dtpWithdrawn.SelectedDate = _student.DateWithdrawn.Value;
            }
            chkWithdrawn.IsChecked = _student.DateWithdrawn.HasValue;

            Maintenance.GradeLevelShorts.ForEach(o => cmbGradeLevel.Items.Add(o));
            cmbGradeLevel.Text = _student.GradeLevel;

            dgvGrades.ItemsSource          = Grades;
            dgvSelfDevelopment.ItemsSource = SDScores;

            grdStudentReport.ItemsSource = _student.StudentReports();

            genReport.Visibility = ViewUtils.IsVisible(UserViewModel.CurrentUser.CanExportReportCards);


            /*
             * cmbMarkingPeriod.ItemsSource =
             *  MarkingPeriods.Singleton.OrderByDescending(q => q.EndDate).Where(q => student.AttendedDuring(q));
             *
             * var periods = new HashSet<string>();
             * cmbMarkingPeriod.ItemsSource = student.Grades.Select(g => MarkingPeriodKey.Parse(g.Quarter))
             *  .Where(period =>
             *  {
             *      var hadItem = periods.Contains(period.ToString());
             *      if (!hadItem) periods.Add(period.ToString());
             *      return !hadItem;
             *  })
             *  .OrderByDescending(period => period.ToString())
             *  .ThenBy(period => period.Quarter);
             * if (cmbMarkingPeriod.Items.Count > 0)
             * {
             * cmbMarkingPeriod.SelectedIndex = 0;
             * genReport.IsEnabled = true;
             * }
             * else
             * {
             * genReport.IsEnabled = false;
             * }
             */
        }