コード例 #1
0
ファイル: TeacherList.cs プロジェクト: BesuglovS/UchOtd
        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);
        }
コード例 #2
0
ファイル: tfdView.cs プロジェクト: BesuglovS/Schedule
 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;
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
 public TeacherForDisciplineView(TeacherForDiscipline tfd)
 {
 }
コード例 #6
0
 public MySqlTeacherForDiscipline(TeacherForDiscipline tfd)
 {
     TeacherForDisciplineId = tfd.TeacherForDisciplineId;
     TeacherId = tfd.Teacher.TeacherId;
     DisciplineId = tfd.Discipline.DisciplineId;
 }