Example #1
0
 /// <summary>
 /// Добавление новой записи в расписание
 /// </summary>
 /// <param name="dayOfWeek">День недели</param>
 /// <param name="weekType">Первая или вторая неделя</param>
 /// <param name="subject">Предмет</param>
 /// <param name="subjectNumber">Номер предмета в расписании</param>
 public void AddEntry(DayOfWeek dayOfWeek, int weekType, Subject subject, int subjectNumber)
 {
     entries.Add(new SchedulesEntry()
         {
             DayOfWeek = dayOfWeek,
             Subject = subject,
             WeekType = weekType,
             SubjNumber = subjectNumber
         });
 }
Example #2
0
 public static void AddSubject(Subject subj)
 {
     using (var session = SessionFactory.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(subj);
             transaction.Commit();
         }
     }
 }
Example #3
0
 /// <summary>
 /// Изменить запись в расписании
 /// </summary>
 /// <param name="dayOfWeek">День недели</param>
 /// <param name="weekType">Первая или вторая неделя</param>
 /// <param name="subjNumber">Номер предмета в расписании</param>
 /// <param name="subject">Новый предмет, null - удалить запись</param>
 public void UpdateEntry(DayOfWeek dayOfWeek, int weekType, int subjNumber, Subject subject)
 {
     var entry = entries.Where(x => x.DayOfWeek == dayOfWeek && x.WeekType == weekType && x.SubjNumber == subjNumber).First();
     if (subjects != null)
     {
         entry.Subject = subject;
         DBConnection.AddScheduleEntry(entry);
     }
     else
         DBConnection.RemoveScheduleEntry(entry);
 }
Example #4
0
 public void RemoveSubject(Subject subj)
 {
     subjects.Remove(subj);
     DBConnection.RemoveSubject(subj);
 }
Example #5
0
 public static void RemoveSubject(Subject subj)
 {
     using (var session = SessionFactory.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.Delete(subj);
             transaction.Commit();
         }
     }
 }
Example #6
0
 /// <summary>
 /// Получить количество пропусков для студента за период по одному предмету
 /// </summary>
 /// <param name="studId">Номер студента в журнале</param>
 /// <param name="subject">Предмет</param>
 /// <param name="from">Начало диапазона</param>
 /// <param name="to">Конец диапазона</param>
 /// <returns></returns>
 public Pass StudentMissed(int studId, Subject subject, DateTime from, DateTime to)
 {
     Pass pass = new Pass();
     foreach (var entry in journal.GetEntriesForStudent(studId, from, to).Where(x => x.DaySchedules.Subject == subject))
     {
         if (entry.Absent > 0)
             if (entry.Valid)
             {
                 pass.ValidHours += entry.Absent;
                 pass.ValidLessons++;
             }
             else
             {
                 pass.NotValidHours += entry.Absent;
                 pass.NotValidLessons++;
             }
     }
     return pass;
 }