Пример #1
0
        // Generate a student grade report as a Word document.
        public void GenerateStudentReport(LocalStudent studentData, string reportPath)
        {
            // Ensure that the WordWrapper is disposed when the method finishes
            using (var wrapper = new WordWrapper())
            {
                // Create a new Word document in memory
                wrapper.CreateBlankDocument();

                // Add a heading to the document
                wrapper.AppendHeading(String.Format("Grade Report: {0} {1}", studentData.FirstName, studentData.LastName));
                wrapper.InsertCarriageReturn();
                wrapper.InsertCarriageReturn();

                // Output the details of each grade for the student
                foreach (var grade in SessionContext.CurrentGrades)
                {
                    // TODO: Exercise 2: Task 2a: Use the IncludeProcessor to determine which fields in the Grade object are tagged

                    // TODO: Exercise 2: Task 2b: Output each tagged item, using the format specified by the properties of the IncludeInReport attribute for each item

                    wrapper.InsertCarriageReturn();
                }

                // Save the Word document
                wrapper.SaveAs(reportPath);
            }
        }
        public void Refresh()
        {
            ServiceUtils utils = new ServiceUtils();

            var students = utils.GetUnassignedStudents();

            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            list.ItemsSource = null;
            list.ItemsSource = resultData;

            if (resultData.Count == 0)
            {
                txtMessage.Visibility    = Visibility.Visible;
                listContainer.Visibility = Visibility.Collapsed;
            }
            else
            {
                txtMessage.Visibility    = Visibility.Collapsed;
                listContainer.Visibility = Visibility.Visible;
            }
        }
Пример #3
0
        // Update the display with the details of the specified student and retrieve the grades for this student
        private async Task DisplayStudentDetailsAndGrades(Student student)
        {
            try
            {
                LocalStudent child = new LocalStudent()
                {
                    Record = student
                };

                // Display the photo for ths stdudent by using databinding
                studentPhoto.DataContext = child;

                // Find the grades for the student and display them
                var grades = await _context.GetGradesByStudent(student.UserId);

                DisplayGrades(grades);
            }
            catch (DataServiceQueryException ex)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}",
                                              ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}", e.Message));
            }
        }
Пример #4
0
        // TODO: Exercise 1: Task 2a: Generate a student grade report as a Word document.
        public void GenerateStudentReport(LocalStudent studentData, string reportPath)
        {
            WordWrapper wrapper = new WordWrapper();

            // Create a new Word document in memory
            wrapper.CreateBlankDocument();

            // Add a heading to the document
            wrapper.AppendHeading(String.Format("Grade Report: {0} {1}", studentData.FirstName, studentData.LastName));
            wrapper.InsertCarriageReturn();
            wrapper.InsertCarriageReturn();

            // Output the details of each grade for the student
            foreach (var grade in SessionContext.CurrentGrades)
            {
                wrapper.AppendText(grade.SubjectName, true, true);
                wrapper.InsertCarriageReturn();
                wrapper.AppendText("Assessment: " + grade.Assessment, false, false);
                wrapper.InsertCarriageReturn();
                wrapper.AppendText("Date: " + grade.AssessmentDateString, false, false);
                wrapper.InsertCarriageReturn();
                wrapper.AppendText("Comment: " + grade.Comments, false, false);
                wrapper.InsertCarriageReturn();
                wrapper.InsertCarriageReturn();
            }

            // Save the Word document
            wrapper.SaveAs(reportPath);
        }
        // Generate a student grade report as a Word document.
        public void GenerateStudentReport(LocalStudent studentData, string reportPath)
        {
            // Ensure that the WordWrapper is disposed when the method finishes
            using (var wrapper = new WordWrapper())
            {
                // Create a new Word document in memory
                wrapper.CreateBlankDocument();

                // Add a heading to the document
                wrapper.AppendHeading(String.Format("Grade Report: {0} {1}", studentData.FirstName, studentData.LastName));
                wrapper.InsertCarriageReturn();
                wrapper.InsertCarriageReturn();

                // Output the details of each grade for the student
                foreach (var grade in SessionContext.CurrentGrades)
                {
                    // Use the IncludeProcessor to determine which fields in the Grade object are tagged
                    List <FormatField> itemsToReport = IncludeProcessor.GetItemsToInclude(grade);

                    // Output each tagged item, using the format specified by the properties of the IncludeInReport attribute for each item
                    foreach (FormatField item in itemsToReport)
                    {
                        wrapper.AppendText(item.Label == string.Empty ? item.Value : item.Label + ": " + item.Value, item.IsBold, item.IsUnderlined);
                        wrapper.InsertCarriageReturn();
                    }
                    wrapper.InsertCarriageReturn();
                }

                // Encrypt and save the Word document
                wrapper.EncryptAndSaveToDisk(reportPath);
            }
        }
Пример #6
0
        // TODO: Exercise 1: Task 3a: Mark StudentsPage.Refresh as an asynchronous method
        public void Refresh()
        {
            ServiceUtils utils = new ServiceUtils();

            // TODO: Exercise 1: Task 3g: Invoke GetStudentsByTeacher asychronously and pass the OnGetStudentsByTeacherComplete callback as the second argument
            var students = utils.GetStudentsByTeacher(SessionContext.UserName);

            // TODO: Exercise 1: Task 3b: Relocate the remaining code in this method to create the OnGetStudentsByTeacherComplete callback (in the Callbacks region)
            // Iterate through the returned set of students, construct a local student object list
            // and then data bind this to the list item template
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            // TODO: Exercise 1: Task 3c: Use a Dispatcher object to update the UI
            list.ItemsSource = resultData;
            txtClass.Text    = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);
        }
Пример #7
0
        private void OnGetUnassignedStudentsComplete(IEnumerable <Student> students)
        {
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            this.Dispatcher.Invoke(() =>
            {
                list.ItemsSource = null;
                list.ItemsSource = resultData;

                if (resultData.Count == 0)
                {
                    txtMessage.Visibility    = Visibility.Visible;
                    listContainer.Visibility = Visibility.Collapsed;
                }
                else
                {
                    txtMessage.Visibility    = Visibility.Collapsed;
                    listContainer.Visibility = Visibility.Visible;
                }
            });
        }
Пример #8
0
        public void Refresh()
        {
            // Find all students for the current teacher
            ServiceUtils utils = new ServiceUtils();

            var students = utils.GetStudentsByTeacher(SessionContext.UserName);

            // Iterate through the returned set of students, construct a local student object list
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };
                resultData.Add(student);
            }

            // TODO: Exercise 1: Task 5a: Bind the list of students to the "list" ItemsControl
            list.ItemsSource = resultData;

            txtClass.Text = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);


            txtClass.Text = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);
        }
Пример #9
0
        private void Child_Click(object sender, MouseButtonEventArgs e)
        {
            LocalStudent child = (sender as TextBlock).Tag as LocalStudent;

            Refresh(child.FirstName, child.LastName);
            SessionContext.CurrentStudent = child;
        }
Пример #10
0
        private void RemoveStudent_Click(object sender, MouseButtonEventArgs e)
        {
            LocalStudent student = (sender as Grid).Tag as LocalStudent;

            MessageBoxResult button = MessageBox.Show("Would you like to remove the student?", "Student", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (button == MessageBoxResult.Yes)
            {
                ServiceUtils utils = new ServiceUtils();
                utils.RemoveStudent(SessionContext.CurrentTeacher, student.Record);
                Refresh();
            }
        }
Пример #11
0
        private async void Student_Click(object sender, MouseButtonEventArgs e)
        {
            LocalStudent student = (sender as StudentPhoto).DataContext as LocalStudent;

            MessageBoxResult button = MessageBox.Show("Would you like to add the student?", "Student", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (button == MessageBoxResult.Yes)
            {
                ServiceUtils utils = new ServiceUtils();
                await utils.AddStudent(SessionContext.CurrentTeacher, student.Record);

                Refresh();
            }
        }
Пример #12
0
        // Callback that displays the list of students for a teacher
        private void OnGetStudentsByTeacherComplete(IEnumerable <Student> students)
        {
            // Iterate through the set of students, construct a local student object list
            // and then data bind this to the list item template
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            this.Dispatcher.Invoke(() => { list.ItemsSource = resultData;
                                           txtClass.Text    = String.Format("Class {0}", SessionContext.CurrentTeacher.Class); });
        }
Пример #13
0
        // TODO: Exercise 1: Task 3b: Implement the OnGetStudentsByTeacherComplete callback to display the students for a teacher here
        private void OnGetStudentsByTeacherComplete(IEnumerable <Student> students)
        {
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            // TODO: Exercise 1: Task 3d: Use a Dispatcher object to update the UI
            this.Dispatcher.Invoke(() => {
                list.ItemsSource = resultData;
                txtClass.Text    = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);
            });
        }
Пример #14
0
        // Display the students for a parent
        private void OnGetStudentsByParentComplete(IEnumerable <Student> students)
        {
            // Display the details for the first child
            try
            {
                foreach (var s in students)
                {
                    LocalStudent child = new LocalStudent();
                    child.Record = s;

                    SessionContext.CurrentStudent = child;
                    this.Dispatcher.Invoke(() => { GotoStudentProfile(); });
                    break;
                }
            }
            catch (DataServiceQueryException ex)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}",
                                              ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
            }
        }
Пример #15
0
        // Update the display with the details of the specified student and retrieve the grades for this student
        private void DisplayStudentDetailsAndGrades(Student student)
        {
            try
            {
                LocalStudent child = new LocalStudent()
                {
                    Record = student
                };

                // Find the grades for the student and display them
                var grades = _context.GetGradesByStudent(student.UserId);
                DisplayGrades(grades);
            }
            catch (DataServiceQueryException ex)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}",
                                              ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}", e.Message));
            }
        }
Пример #16
0
        // TODO: Exercise 1: Task 3b: Implement the OnGetStudentsByTeacherComplete callback to display the students for a teacher here
        private void OnGetStudentsByTeacherComplete(IEnumerable <Student> students)
        {
            // TODO: Exercise 1: Task 3c: Relocate the remaining code in this method to create the OnGetStudentsByTeacherComplete callback (in the Callbacks region)
            // Iterate through the returned set of students, construct a local student object list
            // and then data bind this to the list item template
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            // TODO: Exercise 1: Task 3d: Use a Dispatcher object to update the UI
            this.Dispatcher.Invoke(() => {
                list.ItemsSource = resultData;
                txtClass.Text    = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);
            });
        }
        public void Refresh()
        {
            ServiceUtils utils = new ServiceUtils();

            var students = utils.GetStudentsByTeacher(SessionContext.UserName);

            // Iterate through the returned set of students, construct a local student object list
            // and then data bind this to the list item template
            List <LocalStudent> resultData = new List <LocalStudent>();

            foreach (Student s in students)
            {
                LocalStudent student = new LocalStudent()
                {
                    Record = s
                };

                resultData.Add(student);
            }

            list.ItemsSource = resultData;
            txtClass.Text    = String.Format("Class {0}", SessionContext.CurrentTeacher.Class);
        }
Пример #18
0
        // Display the names of the students for a parent
        private void OnGetStudentsByParentComplete(IEnumerable <Student> students)
        {
            try
            {
                // Convert the list of students from the format provided by the dataservice to the format displayed by the application
                List <LocalStudent> studentList = new List <LocalStudent>();
                foreach (Student s in students)
                {
                    LocalStudent child = new LocalStudent()
                    {
                        Record = s
                    };
                    studentList.Add(child);
                }

                // Use databinding to display the student names
                this.Dispatcher.Invoke(() => { listChild.ItemsSource = studentList; });
            }
            catch (DataServiceQueryException ex)
            {
                MessageBox.Show(String.Format("Error: {0} - {1}",
                                              ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
            }
        }
Пример #19
0
 public StudentEventArgs(LocalStudent s)
 {
     Child = s;
 }
Пример #20
0
        public async void Refresh()
        {
            if (SessionContext.Role == "")
            {
                GotoLogon();
                return;
            }

            // Databind Name
            ServiceUtils context = new ServiceUtils();

            try
            {
                switch (SessionContext.Role)
                {
                case "Student":
                    // Get the details of the current user (which must be a student)
                    var student = await context.GetStudent(SessionContext.UserName);

                    // Display the name of the student
                    try
                    {
                        LocalStudent localStudent = new LocalStudent();
                        localStudent.Record           = student;
                        SessionContext.CurrentStudent = localStudent;
                        txtName.Text = String.Format("Welcome {0} {1}!", localStudent.FirstName, localStudent.LastName);
                    }
                    catch (DataServiceQueryException ex)
                    {
                        MessageBox.Show(String.Format("Error: {0} - {1}",
                                                      ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
                    }

                    // Display the details of the student
                    GotoStudentProfile();
                    break;

                case "Parent":
                    // Get the details of the current user (which must be a parent)
                    var parent = await context.GetParent(SessionContext.UserName);

                    // Display the name of the parent
                    try
                    {
                        SessionContext.CurrentParent = parent;
                        txtName.Text = String.Format("Welcome {0} {1}!", parent.FirstName, parent.LastName);
                    }
                    catch (DataServiceQueryException ex)
                    {
                        MessageBox.Show(String.Format("Error: {0} - {1}",
                                                      ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
                    }

                    // Find all the students that are children of this parent
                    await context.GetStudentsByParent(SessionContext.UserName, OnGetStudentsByParentComplete);

                    break;

                case "Teacher":
                    // Get the details of the current user (which must be a teacher)
                    var teacher = await context.GetTeacher(SessionContext.UserName);

                    // Display the details for the teacher
                    try
                    {
                        SessionContext.CurrentTeacher = teacher;
                        txtName.Text = String.Format("Welcome {0} {1}!", teacher.FirstName, teacher.LastName);

                        // Display the students in the class taught by this teacher
                        GotoStudentsPage();
                    }
                    catch (DataServiceQueryException ex)
                    {
                        MessageBox.Show(String.Format("Error: {0} - {1}",
                                                      ex.Response.StatusCode.ToString(), ex.Response.Error.Message));
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error fetching details", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }