Esempio n. 1
0
        private void TimeFree(DataGridViewCell cell)
        {
            SchedulePointer pointer = cell.Tag as SchedulePointer;

            SetCellFreeStyle(cell, pointer);

            ScheduleLesson lesson1 = Schedule.GetLesson(pointer.Time1, pointer.Room1);

            if (lesson1 != null)
            {
                lesson1.Clear();
            }

            ScheduleLesson lesson2 = Schedule.GetLesson(pointer.Time2, pointer.Room2);

            if (lesson2 != null)
            {
                lesson2.Clear();
            }

            string Name = dgvSchedule.Rows[cell.RowIndex].Cells[0].Value.ToString();

            Schedule.Employments.RemoveInView(ViewShedule, new Employment(Name, pointer.Time1, ReasonEmployment.Another));
            Schedule.Employments.RemoveInView(ViewShedule, new Employment(Name, pointer.Time2, ReasonEmployment.Another));
        }
Esempio n. 2
0
        private void ExchangeLessons(ScheduleLesson item1, ScheduleLesson item2, ScheduleTime time1, ScheduleTime time2)
        {
            if (item1 != null && item2 != null)
            {
                ScheduleLesson tmp1  = item1.Copy();
                ScheduleLesson less1 = Schedule.GetLesson(time1, item1.Room);
                ScheduleLesson less2 = Schedule.GetLesson(time2, item2.Room);

                Schedule.Employments.Remove(less1.Teacher, less1.Groups, less1.Room, less1.Time);
                Schedule.Employments.Remove(less2.Teacher, less2.Groups, less2.Room, less2.Time);

                less1.UpdateFields(item1.Teacher, item1.Discipline, item1.Groups, item1.Type, item2.Dates);
                less1.Time = item2.Time.Copy();
                less1.Room = item2.Room;

                less2.UpdateFields(item2.Teacher, item2.Discipline, item2.Groups, item2.Type, tmp1.Dates);
                less2.Time = tmp1.Time.Copy();
                less2.Room = tmp1.Room;

                Schedule.Employments.Add(less2.Teacher, less2.Groups, less2.Room, less2.Time, ReasonEmployment.UnionLesson);
                Schedule.Employments.Add(less1.Teacher, less1.Groups, less1.Room, less1.Time, ReasonEmployment.UnionLesson);
            }
            else if (item1 == null && item2 != null)
            {
                ScheduleLesson lsn = Schedule.GetLesson(time1, item2.Room);
                if (lsn.GroupsDescription != "" || lsn.Teacher != "" || lsn.Discipline != "")
                {
                    MessageBox.Show("Занято для " + item2.Week.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                ScheduleLesson lsn2 = Schedule.GetLesson(time2, item2.Room).Copy();
                Schedule.Employments.Remove(lsn2.Teacher, lsn2.Groups, lsn2.Room, lsn2.Time);
                lsn.UpdateFields(item2.Teacher, item2.Discipline, item2.Groups, item2.Type, lsn.Dates);
                item2.Clear();
                Schedule.Employments.Add(lsn.Teacher, lsn.Groups, lsn.Room, lsn.Time, ReasonEmployment.UnionLesson);
            }
            else if (item1 != null && item2 == null)
            {
                ScheduleLesson lsn = Schedule.GetLesson(time2, item1.Room);
                if (lsn.GroupsDescription != "" || lsn.Teacher != "" || lsn.Discipline != "")
                {
                    MessageBox.Show("Занято для " + item1.Week.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                ScheduleLesson lsn2 = Schedule.GetLesson(time1, item1.Room).Copy();
                Schedule.Employments.Remove(lsn2.Teacher, lsn2.Groups, lsn2.Room, lsn2.Time);
                lsn.UpdateFields(item1.Teacher, item1.Discipline, item1.Groups, item1.Type, lsn.Dates);
                item1.Clear();
                Schedule.Employments.Add(lsn.Teacher, lsn.Groups, lsn.Room, lsn.Time, ReasonEmployment.UnionLesson);
            }
        }