Пример #1
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (!((cmbDiscipline1.Text != "" && cmbRooms1.Text != "" &&
                   cmbTypeLesson1.SelectedValue != null && cmbTeacher1.Text != "") ||
                  ((cmbDiscipline1.Text == "" && cmbRooms1.Text == "" &&
                    cmbTypeLesson1.SelectedValue == null && cmbTeacher1.Text == ""))))
            {
                MessageBox.Show("Введены не все \n\rзначения для 1-2 недели", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!((cmbDiscipline2.Text != "" && cmbRooms2.Text != "" &&
                   cmbTypeLesson2.SelectedValue != null && cmbTeacher2.Text != "") ||
                  ((cmbDiscipline2.Text == "" && cmbRooms2.Text == "" &&
                    cmbTypeLesson2.SelectedValue == null && cmbTeacher2.Text == ""))))
            {
                MessageBox.Show("Введены не все \n\rзначения для 3-4 недели", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Lesson1 != null)
            {
                Employments.Remove(Lesson1.Teacher, Lesson1.Groups, Lesson1.Room, Time1);
            }

            if (Lesson1 == null)
            {
                Lesson1 = Shedule.GetLesson(Time1, cmbRooms1.Text);
            }

            if (Lesson1 != null)
            {
                Lesson1.Discipline = cmbDiscipline1.Text;

                Lesson1.Room = cmbRooms1.Text;

                Lesson1.Type = (LessonType)cmbTypeLesson1.SelectedValue;

                Lesson1.Teacher = cmbTeacher1.Text;

                Lesson1.Groups.Clear();
                foreach (ListViewItem Item in lvSelectGroup1.Items)
                {
                    Lesson1.Groups.Add(Item.Text);
                }

                Lesson1.Dates.Clear();
                foreach (ListViewItem Item in lvDates1.Items)
                {
                    Lesson1.Dates.Add(Convert.ToDateTime(Item.Text));
                }

                Employments.Add(Lesson1.Teacher, Lesson1.Groups, Lesson1.Room, Time1, ReasonEmployment.UnionLesson);
            }

            //-------------------------------------------
            if (Lesson2 != null)
            {
                Employments.Remove(Lesson2.Teacher, Lesson2.Groups, Lesson2.Room, Time2);
            }

            if (Lesson2 == null)
            {
                Lesson2 = Shedule.GetLesson(Time2, cmbRooms2.Text);
            }

            if (Lesson2 != null)
            {
                Lesson2.Discipline = cmbDiscipline2.Text;

                Lesson2.Room = cmbRooms2.Text;

                Lesson2.Type = (LessonType)cmbTypeLesson2.SelectedValue;

                Lesson2.Teacher = cmbTeacher2.Text;

                Lesson2.Groups.Clear();
                foreach (ListViewItem Item in lvSelectGroup2.Items)
                {
                    Lesson2.Groups.Add(Item.Text);
                }

                Lesson2.Dates.Clear();
                foreach (ListViewItem row in lvDates2.Items)
                {
                    Lesson2.Dates.Add(Convert.ToDateTime(row.Text));
                }

                Employments.Add(Lesson2.Teacher, Lesson2.Groups, Lesson2.Room, Time2, ReasonEmployment.UnionLesson);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;

            this.Close();
        }
Пример #2
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);
                    }
                }
            }
        }