Example #1
0
        private void ViewSelectLesson(DataGridViewCell cell)
        {
            SchedulePointer Tag = cell.Tag as SchedulePointer;

            ScheduleLesson lesson1 = Schedule.GetLesson(Tag.Time1, Tag.Room1);
            ScheduleLesson lesson2 = Schedule.GetLesson(Tag.Time2, Tag.Room2);

            if (NumSelectLesson == 1)
            {
                SetDataSelectLessonForm(lesson1, lesson2, txtTeacher1, txtDiscipline1, txtRoom1, txtTypeLesson1);

                L1 = lesson1;
                L2 = lesson2;
                T1 = Tag.Time1.Copy();
                T2 = Tag.Time2.Copy();
            }
            else if (NumSelectLesson == 2)
            {
                SetDataSelectLessonForm(lesson1, lesson2, txtTeacher2, txtDiscipline2, txtRoom2, txtTypeLesson2);

                L3 = lesson1;
                L4 = lesson2;
                T3 = Tag.Time1.Copy();
                T4 = Tag.Time2.Copy();
            }

            NumSelectLesson = 0;
        }
Example #2
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));
        }
Example #3
0
        private void TimeBlocked(DataGridViewCell cell)
        {
            TimeFree(cell);

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

            SetCellBlockedStyle(cell, pointer.Time1, pointer.Time2);

            Schedule.Employments.AddInView(ViewShedule, new Employment(Name, pointer.Time1, ReasonEmployment.UserBlocked));
            Schedule.Employments.AddInView(ViewShedule, new Employment(Name, pointer.Time2, ReasonEmployment.UserBlocked));
        }
Example #4
0
        void dgvSchedule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex <= 1 || e.RowIndex < 0)
            {
                return;
            }

            LessonForm      frmLesson = new LessonForm(curSheduleType);
            SchedulePointer Tag       = dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as SchedulePointer;

            frmLesson.txtSheduleTime.Text = ScheduleTime.GetDescription(Tag.Time1);
            frmLesson.Employments         = Schedule.Employments;
            frmLesson.ds      = ScheduleDataSet;
            frmLesson.Adapter = EducationAdapter;
            frmLesson.Rooms   = Rooms;
            frmLesson.curClmn = dgvSchedule.CurrentCell.ColumnIndex;

            frmLesson.Time1   = Tag.Time1;
            frmLesson.Lesson1 = Schedule.GetLesson(Tag.Time1, Tag.Room1);

            frmLesson.Time2   = Tag.Time2;
            frmLesson.Lesson2 = Schedule.GetLesson(Tag.Time2, Tag.Room2);

            frmLesson.Shedule = Schedule;

            if (frmLesson.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                UpdateTableShedule();
                if (curSheduleType == scheduleType.exams)
                {
                    if (frmLesson.Lesson1 != null)
                    {
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 1], frmLesson.Time1.Week);
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 2], frmLesson.Time1.Week);
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 3], frmLesson.Time1.Week);
                    }
                    if (frmLesson.Lesson2 != null)
                    {
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 1], frmLesson.Time2.Week);
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 2], frmLesson.Time2.Week);
                        OneDayTimeBlocked(dgvSchedule.Rows[e.RowIndex].Cells[e.ColumnIndex + 3], frmLesson.Time2.Week);
                    }
                }
            }
        }
Example #5
0
        private void OneDayTimeBlocked(DataGridViewCell cell, Week weekNum)
        {
            TimeFree(cell);

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

            // SetCellBlockedStyle(cell, pointer.Time1, pointer.Time1);

            if (weekNum == Week.FirstWeek || weekNum == Week.SecondWeek)
            {
                Schedule.Employments.AddInView(ViewShedule, new Employment(Name, pointer.Time1, ReasonEmployment.UserBlocked));
            }
            else
            {
                Schedule.Employments.AddInView(ViewShedule, new Employment(Name, pointer.Time2, ReasonEmployment.UserBlocked));
            }
        }
Example #6
0
 private static void SetCellFreeStyle(DataGridViewCell cell, SchedulePointer pointer)
 {
     cell.Value           = String.Empty;
     cell.Style.BackColor = (pointer.Time1.DayNumber > (int)ScheduleClasses.Day.Friday) ? Color.LightBlue : new DataGridViewCellStyle().BackColor;
 }