public MySQLScheduleNote(ScheduleNote note) { ScheduleNoteId = note.ScheduleNoteId; LessonId = note.Lesson.LessonId; Text = note.Text; LateAmount = note.LateAmount; }
public ScheduleNoteView(ScheduleNote note) { ScheduleNoteId = note.ScheduleNoteId; Text = note.Text; LateAmount = note.LateAmount; LessonString = ((note.Lesson != null) && (note.IsLesson)) ? ((note.Lesson.State == 1) ? "+" : ((note.Lesson.State == 0) ? "-" : note.Lesson.State.ToString())) + " " + note.Lesson.Calendar.Date.ToString("dd.MM.yyyy") + " " + note.Lesson.Ring.Time.ToString("HH:mm") + " " + note.Lesson.TeacherForDiscipline.Teacher.FIO + " " + note.Lesson.TeacherForDiscipline.Discipline.Name + " " + note.Lesson.TeacherForDiscipline.Discipline.StudentGroup.Name : ""; }
public ScheduleNote AddScheduleNote(ScheduleNote sNote) { using (var context = new ScheduleContext(ConnectionString)) { sNote.ScheduleNoteId = 0; sNote.Lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == sNote.Lesson.TeacherForDiscipline.TeacherForDisciplineId); sNote.Lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == sNote.Lesson.Calendar.CalendarId); sNote.Lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == sNote.Lesson.Ring.RingId); sNote.Lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == sNote.Lesson.Auditorium.AuditoriumId); context.ScheduleNotes.Add(sNote); context.SaveChanges(); return sNote; } }
public void UpdateScheduleNote(ScheduleNote sNote) { using (var context = new ScheduleContext(ConnectionString)) { var curNote = context.ScheduleNotes.FirstOrDefault(sn => sn.ScheduleNoteId == sNote.ScheduleNoteId); curNote.Lesson = sNote.Lesson; curNote.Text = sNote.Text; context.SaveChanges(); } }
private void add_Click(object sender, EventArgs e) { var lesson = (Lesson) LessonsList.SelectedValue; var newNote = new ScheduleNote { IsLesson = IsLesson.Checked, Lesson = lesson, Text = NoteText.Text, LateAmount = (int)LateCount.Value }; _repo.ScheduleNotes.AddScheduleNote(newNote); var notes = _repo.ScheduleNotes.GetAllScheduleNotes(); RefreshView(notes); }