private void addTFD_Click(object sender, EventArgs e) { if (AllDisciplinesList.SelectedCells.Count == 0) { MessageBox.Show("Не выделена дисциплина для добавления."); return; } if (TeacherListView.SelectedCells.Count == 0) { MessageBox.Show("Не выделен преподаватель для добавления дисциплины."); return; } var teacher = ((List<Teacher>)TeacherListView.DataSource)[TeacherListView.SelectedCells[0].RowIndex]; var discView = ((List<DisciplineView>)AllDisciplinesList.DataSource)[AllDisciplinesList.SelectedCells[0].RowIndex]; var discipline = _repo.Disciplines.GetDiscipline(discView.DisciplineId); if (_repo.TeacherForDisciplines.GetFiltredTeacherForDiscipline(tfdisc => tfdisc.Discipline.DisciplineId == discipline.DisciplineId).Count != 0) { MessageBox.Show("Дисциплина уже назначена."); return; } var tfd = new TeacherForDiscipline { Teacher = teacher, Discipline = discipline }; _repo.TeacherForDisciplines.AddTeacherForDiscipline(tfd); RefreshTeacherDisciplines(teacher); RefreshView((int)RefreshType.DisciplinesOnly); }
public tfdView(TeacherForDiscipline tfd) { TeacherForDisciplineId = tfd.TeacherForDisciplineId; tfdSummary = tfd.Teacher.FIO + " " + tfd.Discipline.Name + " " + tfd.Discipline.AuditoriumHours + "@" + tfd.Discipline.LectureHours + "/" + tfd.Discipline.PracticalHours + " " + Constants.Constants.Attestation[tfd.Discipline.Attestation] + " " + tfd.Discipline.StudentGroup.Name; }
public TeacherForDiscipline AddTeacherForDiscipline(TeacherForDiscipline teacherForDiscipline) { using (var context = new ScheduleContext(ConnectionString)) { teacherForDiscipline.TeacherForDisciplineId = 0; teacherForDiscipline.Teacher = context.Teachers.FirstOrDefault(t => t.TeacherId == teacherForDiscipline.Teacher.TeacherId); teacherForDiscipline.Discipline = context.Disciplines.FirstOrDefault(d => d.DisciplineId == teacherForDiscipline.Discipline.DisciplineId); context.TeacherForDiscipline.Add(teacherForDiscipline); context.SaveChanges(); return teacherForDiscipline; } }
public void UpdateTeacherForDiscipline(TeacherForDiscipline teacherForDiscipline) { using (var context = new ScheduleContext(ConnectionString)) { var curTeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == teacherForDiscipline.TeacherForDisciplineId); teacherForDiscipline.Teacher = context.Teachers.FirstOrDefault(t => t.TeacherId == teacherForDiscipline.Teacher.TeacherId); teacherForDiscipline.Discipline = context.Disciplines.FirstOrDefault(d => d.DisciplineId == teacherForDiscipline.Discipline.DisciplineId); context.SaveChanges(); } }
public TeacherForDisciplineView(TeacherForDiscipline tfd) { }
public MySqlTeacherForDiscipline(TeacherForDiscipline tfd) { TeacherForDisciplineId = tfd.TeacherForDisciplineId; TeacherId = tfd.Teacher.TeacherId; DisciplineId = tfd.Discipline.DisciplineId; }