public DisciplineName(int disciplineNameId, Discipline discipline, StudentGroup studentGroup, string name) { DisciplineNameId = disciplineNameId; Discipline = discipline; StudentGroup = studentGroup; Name = name; }
public MySQLDiscipline(Discipline discipline) { DisciplineId = discipline.DisciplineId; Name = discipline.Name; Attestation = discipline.Attestation; AuditoriumHours = discipline.AuditoriumHours; LectureHours = discipline.LectureHours; PracticalHours = discipline.PracticalHours; StudentGroupId = discipline.StudentGroup.StudentGroupId; }
public DisciplineTextView(Discipline discipline) { const string separator = " @ "; DisciplineId = discipline.DisciplineId; DisciplineSummary = ""; DisciplineSummary += discipline.StudentGroup.Name + separator; DisciplineSummary += discipline.Name + separator; DisciplineSummary += (Constants.Attestation.ContainsKey(discipline.Attestation) ? Constants.Attestation[discipline.Attestation] : "") + separator; DisciplineSummary += discipline.AuditoriumHours; }
public MySqlDiscipline(Discipline discipline) { DisciplineId = discipline.DisciplineId; Name = discipline.Name; Attestation = discipline.Attestation; AuditoriumHours = discipline.AuditoriumHours; AuditoriumHoursPerWeek = discipline.AuditoriumHoursPerWeek; LectureHours = discipline.LectureHours; PracticalHours = discipline.PracticalHours; CourseProject = discipline.CourseProject; CourseTask = discipline.CourseTask; ControlTask = discipline.ControlTask; Referat = discipline.Referat; Essay = discipline.Essay; StudentGroupId = discipline.StudentGroup.StudentGroupId; }
private void AddClick(object sender, EventArgs e) { int audHours; int.TryParse(AuditoriumHours.Text, out audHours); int lecHours; int.TryParse(LectureHours.Text, out lecHours); int practHours; int.TryParse(PracticalHours.Text, out practHours); if (_repo.FindDiscipline(DisciplineName.Text, Attestation.SelectedIndex, audHours, lecHours, practHours, Group.Text) != null) { MessageBox.Show("Такая дисциплина уже есть."); return; } if (Attestation.SelectedIndex == -1) { Attestation.SelectedIndex = Constants.Constants.Attestation.Where(a => a.Value == "-").FirstOrDefault().Key; } var disciplineGroup = _repo.FindStudentGroup(Group.Text); if (disciplineGroup == null) { disciplineGroup = new StudentGroup { Name = Group.Text }; _repo.AddStudentGroup(disciplineGroup); } var newDiscipline = new Discipline { Attestation = Attestation.SelectedIndex, AuditoriumHours = audHours, LectureHours = lecHours, PracticalHours = practHours, Name = DisciplineName.Text, StudentGroup = disciplineGroup }; _repo.AddDiscipline(newDiscipline); RefreshView(); }
public DisciplineView(ScheduleRepository repo, Discipline discipline) { DisciplineId = discipline.DisciplineId; Name = discipline.Name; Attestation = Constants.Constants.Attestation.ContainsKey(discipline.Attestation) ? Constants.Constants.Attestation[discipline.Attestation] : ""; AuditoriumHours = discipline.AuditoriumHours; LectureHours = discipline.LectureHours; PracticalHours = discipline.PracticalHours; StudentGroupName = discipline.StudentGroup.Name; var tefd = repo.GetFirstFiltredTeacherForDiscipline(tfd => tfd.Discipline.DisciplineId == discipline.DisciplineId); if (tefd != null) { TeacherFIO = tefd.Teacher.FIO; ScheduleHours = repo.getTFDHours(tefd.TeacherForDisciplineId); } else { TeacherFIO = "нет"; ScheduleHours = 0; } }
public Discipline AddDiscipline(Discipline discipline) { using (var context = new ScheduleContext(ConnectionString)) { discipline.StudentGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == discipline.StudentGroup.StudentGroupId); context.Disciplines.Add(discipline); context.SaveChanges(); return discipline; } }
public void UpdateDiscipline(Discipline discipline) { using (var context = new ScheduleContext(ConnectionString)) { var curDiscipline = context.Disciplines.FirstOrDefault(d => d.DisciplineId == discipline.DisciplineId); curDiscipline.Attestation = discipline.Attestation; curDiscipline.AuditoriumHours = discipline.AuditoriumHours; curDiscipline.LectureHours = discipline.LectureHours; curDiscipline.Name = discipline.Name; curDiscipline.PracticalHours = discipline.PracticalHours; curDiscipline.Semester = discipline.Semester; var disciplineGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == discipline.StudentGroup.StudentGroupId); curDiscipline.StudentGroup = disciplineGroup; context.SaveChanges(); } }
public TeacherForDiscipline FindTeacherForDiscipline(Teacher t, Discipline d) { using (var context = new ScheduleContext(ConnectionString)) { return context.TeacherForDiscipline.Include(tfd => tfd.Teacher).Include(tfd => tfd.Discipline.StudentGroup).FirstOrDefault(tfd => tfd.Teacher.TeacherId == t.TeacherId && tfd.Discipline.DisciplineId == d.DisciplineId); } }
private List<int> GetAudIdsFromSelectedDiscipline() { var datasource = (List<DisciplineTextView>)discList.DataSource; var discView = datasource[discList.SelectedIndex]; var dicsId = discView.DisciplineId; _selectedDiscipline = _repo.Disciplines.GetDiscipline(dicsId); var audIds = _repo .CustomDisciplineAttributes .GetFiltredCustomDisciplineAttributes(cda => cda.Discipline.DisciplineId == _selectedDiscipline.DisciplineId && cda.Key == "DisciplineAuditorium") .Select(cda => int.Parse(cda.Value)) .ToList(); return audIds; }
public CustomDisciplineAttribute(Discipline discipline, string key, string value) { Discipline = discipline; Key = key; Value = value; }
private void AddClick(object sender, EventArgs e) { int audHours; int.TryParse(AuditoriumHours.Text, out audHours); int audHoursPerWeek; int.TryParse(AuditoriumHoursPerWeek.Text, out audHoursPerWeek); int lecHours; int.TryParse(LectureHours.Text, out lecHours); int practHours; int.TryParse(PracticalHours.Text, out practHours); if ((checkForDoubleDiscsOnAdding.Checked) && (_repo.Disciplines.FindDiscipline(DisciplineName.Text, Attestation.SelectedIndex, audHours, lecHours, practHours, Group.Text) != null)) { var dialogResult = MessageBox.Show("Такая дисциплина уже есть", "Всё равно добавить?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //do something, in this case nothing } else if (dialogResult == DialogResult.No) { return; } } if (Attestation.SelectedIndex == -1) { Attestation.SelectedIndex = Constants.Attestation.FirstOrDefault(a => a.Value == "-").Key; } var disciplineGroup = _repo.StudentGroups.FindStudentGroup(Group.Text); if (disciplineGroup == null) { disciplineGroup = new StudentGroup { Name = Group.Text }; _repo.StudentGroups.AddStudentGroup(disciplineGroup); } var newDiscipline = new Discipline { Attestation = Attestation.SelectedIndex, AuditoriumHours = audHours, AuditoriumHoursPerWeek = audHoursPerWeek, LectureHours = lecHours, PracticalHours = practHours, Name = DisciplineName.Text, StudentGroup = disciplineGroup, TypeSequence = TypeSequence.Text }; _repo.Disciplines.AddDiscipline(newDiscipline); RefreshView(); }