Example #1
0
        public void FillLessonFromCalendar(Lesson l)
        {
            int slot = SlotFromStringTime(lbReconcileFrom.Text, false);
            cbLessonStart.SelectedIndex = slot;
            l.Start = m_enumTimeSlot[slot];

            slot = SlotFromStringTime(lbReconcileTo.Text, true);
            cbLessonEnd.SelectedIndex = slot;
            l.End = m_enumTimeSlot[slot];

            DateTime dt = DateTime.Now;
            DateTime.TryParse(lbReconcileDate.Text, out dt);
            monthCalLessonDate.SetDate(dt);
            l.Day = dt.ToShortDateString();

            string s = lbReconcileDescription.Text;
            tbLessonComment.Text = s;
            l.Comments = s;
            bool cancelled = !IsStringEmpty(s) &&
                             (s.ToLower().IndexOf("cancel") >= 0);

            l.Room = SetComboByInitial(cbLessonRoom, lbReconcileLocation.Text);

            l.GoogleId = lbReconcileGoogleCalId.Text;

            l.State = SetComboByValue(cbLessonState, 
                            (cancelled ? m_enumState[(int)LessonStates.Cancelled] :
                                         m_enumState[(int)LessonStates.Planned]) );

            string geTitle, geComment;
            string[] geStudents, geTeachers;

            ParseEventDescription( lbReconcileDescription.Text,
                out geTitle, out geStudents, out geTeachers, out geComment);

            for (int i = 0; i < 2 && i < geTeachers.Length; i++)
            {
                string str = ExtractTeacher(geTeachers[i], i+1);
                if (!IsStringEmpty(str))
                    l.SetTeacher(SetComboByValue(LessonTeacherComboBox(i+1), str), i+1);
            }

            for (int i = 0; i < 10 && i < geStudents.Length; i++)
            {
                string str = ExtractStudent(geStudents[i], i+1);
                if (!IsStringEmpty(str))
                    l.SetStudent(SetComboByValue(LessonStudentComboBox(i+1), str), i+1);
            }
        }