private void ToggleAttendance(object sender)
        {
            //WARNING: This is a hack to make this shit work........
            //This code COULD and WILL break if VALUE is not a BOOL array
            Property prop = (Property)sender;

            bool[] values = (bool[])prop.Value;
            //toggle attendance
            values[0] = !values[0];
            //set tardiness to false
            values[1]  = false;
            prop.Value = values;

            DateTime date = GetDateWithCourseTime(DateTime.Parse(prop.Name));

            Console.WriteLine(date);

            //add attendance
            if (values[0])
            {
                Attendance a = new Attendance(Course, Student, "", date, values[1]);
                Attendances.Add(a);
                Attendance.Add(a);
            }
            //remove attendance
            else
            {
                Attendance a = GetAttendanceByDate(date);
                Attendances.Remove(a);
                Attendance.Remove(a);
            }
        }
Пример #2
0
        private bool RegisterAttendance(Course course, Student student, DateTime now)
        {
            bool success = false;

            if (course == null)
            {
                MessageBox.Show("Course not found.", "404 Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                //register attendance
                Attendance attendance = new Attendance(course, student, "127.0.0.1", now, course.IsTardy(now));
                success = !Attendance.HasAttended(attendance);
                if (success)
                {
                    Attendance.Add(attendance);
                }
                else
                {
                    MessageBox.Show("You have already been counted for today.", "Info",
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            return(success);
        }
Пример #3
0
 public void When(PersonLinkedToHappening e) => Attendance.Add(e.HappeningId);