예제 #1
0
 private void lessonBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lessonBox.SelectedIndex != -1)
     {
         selectedLesson = (LessonInstance)lessonBox.SelectedItem;
         lesIndex       = lessonBox.SelectedIndex;
     }
     RefreshAttendAbsent();
 }
예제 #2
0
        public NewTrial(BindingList <Student> allStudents, LessonInstance passed_instance)
        {
            InitializeComponent();
            students = allStudents;
            instance = passed_instance;
            List <Student> displayStudents = new List <Student>();

            displayStudents.AddRange(students);
            displayStudents          = displayStudents.OrderBy(x => x.FirstName).ThenBy(x => x.LastName).ToList <Student>();
            studentBox.DataSource    = displayStudents;
            studentBox.DisplayMember = "FullName";
            studentBox.ValueMember   = "ID";
        }
예제 #3
0
 //THIS is the primary instance creation method
 void CreateDayInstance()
 {
     foreach (Lesson l in allLessons)
     {
         if (scheduleCal.SelectionRange.Start.DayOfWeek.ToString() == l.Day)
         {
             List <Student> absent = new List <Student>();
             List <Student> attend = new List <Student>();
             List <Student> makeup = new List <Student>();
             List <Student> trial  = new List <Student>();
             foreach (Student s in l.Members)
             {
                 attend.Add(s);
             }
             LessonInstance instance = new LessonInstance(l.ID, l.Lvl, l.Day, l.Hour, l.Minute, scheduleCal.SelectionStart, l.Teacher, l.Room, l.Members, attend, absent, makeup, trial);
             bool           exists   = false;
             //Check for a copy of the instance already by ID and day
             foreach (LessonInstance li in allInstances)
             {
                 if (li.ID == instance.ID && li.LessonTime.Day == instance.LessonTime.Day)
                 {
                     exists = true;
                 }
             }
             //If we are looking at a day in the past, do not create the instance
             //if (DateTime.Compare(scheduleCal.SelectionRange.Start, DateTime.Now) > 0)
             //{
             //    if (!exists)
             //        allInstances.Add(instance);
             //}
             if (!exists)
             {
                 allInstances.Add(instance);
             }
             //If the instance exists already, check for any updates in the names
             if (exists)
             {
                 foreach (LessonInstance li in allInstances)
                 {
                     if (li.ID == instance.ID && li.LessonTime.Day == instance.LessonTime.Day)
                     {
                         if (li.Members != instance.Members)
                         {
                             li.Members = instance.Members;
                             foreach (Student s in li.Members)
                             {
                                 bool sExists = false;
                                 foreach (Student absentS in li.Absent)
                                 {
                                     if (s.ID == absentS.ID)
                                     {
                                         sExists = true;
                                     }
                                     if (s.ID == absentS.ID && s.FullName != absentS.FullName)
                                     {
                                         absentS.FirstName = s.FirstName;
                                         absentS.LastName  = s.LastName;
                                     }
                                 }
                                 foreach (Student attendS in li.Attend)
                                 {
                                     if (s.ID == attendS.ID)
                                     {
                                         sExists = true;
                                     }
                                     if (s.ID == attendS.ID && s.FullName != attendS.FullName)
                                     {
                                         attendS.FirstName = s.FirstName;
                                         attendS.LastName  = s.LastName;
                                     }
                                 }
                                 //Only update for present or future classes
                                 if (DateTime.Compare(scheduleCal.SelectionRange.Start, DateTime.Now) >= 0)
                                 {
                                     if (!sExists)
                                     {
                                         li.Attend.Add(s);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }