private void AddEditSchedule()
        {
            var edit = false;
            if (_cell.Tag != null)
                edit = true;
            object obj = null;
            switch (Main.SelectedIndex)
            {
                case 0:
                    obj = TabTeachers.SelectedTab.Tag;
                    break;
                case 1:
                    obj = Auditoriums.SelectedTab.Tag;
                    break;
                case 2:
                    obj = Group.SelectedTab.Tag;
                    break;
            }
            var period = (PeriodInfo)Periods.SelectedTab.Tag;
            switch (Main.SelectedIndex)
            {
                case 1:
                    {

                        var add = new AddParaAuditorium(
                            (AuditoriumInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex, _cell.RowIndex,
                            period.ID_Period,
                            Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                        if (add.ShowDialog() == DialogResult.OK)
                        {
                            if (edit)
                                Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                            foreach (var s in add.Sched)
                                Model.Add.Schedule(s);
                            _cell.Tag = add.Sched;
                        }
                    }
                    break;
                case 0:
                    {
                        var add = new AddParaTeacher(
                            (TeacherInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex, _cell.RowIndex, period.ID_Period,
                            Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                        if (add.ShowDialog() == DialogResult.OK)
                        {
                            if (edit)
                                Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                            foreach (var s in add.Sched)
                                Model.Add.Schedule(s);
                            _cell.Tag = add.Sched;
                        }
                    }
                    break;
                case 2:
                    {
                        var add = new AddParaGroup((GroupInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex,
                            _cell.RowIndex, period.ID_Period,
                            Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                        if (add.ShowDialog() == DialogResult.OK)
                        {
                            if (edit)
                                Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                            foreach (var s in add.Sched)
                                Model.Add.Schedule(s);
                            _cell.Tag = add.Sched;
                        }
                    }
                    break;
            }
            LoadDataGridView();
        }
        private void AddEditSchedule()
        {
            var edit = false;

            if (_cell.Tag != null)
            {
                edit = true;
            }
            object obj = null;

            switch (Main.SelectedIndex)
            {
            case 0:
                obj = TabTeachers.SelectedTab.Tag;
                break;

            case 1:
                obj = Auditoriums.SelectedTab.Tag;
                break;

            case 2:
                obj = Group.SelectedTab.Tag;
                break;
            }
            var period = (PeriodInfo)Periods.SelectedTab.Tag;

            switch (Main.SelectedIndex)
            {
            case 1:
            {
                var add = new AddParaAuditorium(
                    (AuditoriumInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex, _cell.RowIndex,
                    period.ID_Period,
                    Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                if (add.ShowDialog() == DialogResult.OK)
                {
                    if (edit)
                    {
                        Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                    }
                    foreach (var s in add.Sched)
                    {
                        Model.Add.Schedule(s);
                    }
                    _cell.Tag = add.Sched;
                }
            }
            break;

            case 0:
            {
                var add = new AddParaTeacher(
                    (TeacherInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex, _cell.RowIndex, period.ID_Period,
                    Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                if (add.ShowDialog() == DialogResult.OK)
                {
                    if (edit)
                    {
                        Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                    }
                    foreach (var s in add.Sched)
                    {
                        Model.Add.Schedule(s);
                    }
                    _cell.Tag = add.Sched;
                }
            }
            break;

            case 2:
            {
                var add = new AddParaGroup((GroupInfo)obj, ((ScheduleInfo[])_cell.Tag).AsEnumerable(), _cell.ColumnIndex,
                                           _cell.RowIndex, period.ID_Period,
                                           Shcedule.Rows[_cell.RowIndex].Cells[0].Value + " " + Shcedule.Columns[_cell.ColumnIndex].HeaderText, edit);
                if (add.ShowDialog() == DialogResult.OK)
                {
                    if (edit)
                    {
                        Model.Delete.Schedule((ScheduleInfo[])_cell.Tag);
                    }
                    foreach (var s in add.Sched)
                    {
                        Model.Add.Schedule(s);
                    }
                    _cell.Tag = add.Sched;
                }
            }
            break;
            }
            LoadDataGridView();
        }