示例#1
0
 private void SaveAnnotations(bool SaveMany)
 {
     if (currentAnnotation.IdAnnotation == null)
     {
         if (!SaveMany)
         {
             if (!Commons.CheckIfStudentChosen(currentStudent))
             {
                 return;
             }
             currentAnnotation.IdAnnotation = null;
             currentAnnotation.IdAnnotation = db.SaveAnnotation(currentAnnotation, currentStudent);
         }
         else
         {
             foreach (Student s in chosenStudents)
             {
                 currentAnnotation.IdAnnotation = null;
                 currentAnnotation.IdAnnotation = db.SaveAnnotation(currentAnnotation, s);
             }
         }
         return;
     }
     else
     {
         // if IsActive has changed from what is in database then we change dates
         // according to the status
         if (db.GetAnnotation(currentAnnotation.IdAnnotation).IsActive != currentAnnotation.IsActive)
         {
             if (currentAnnotation.IsActive == true)
             {
                 // if it wasn't active and now it is, we set date taken now
                 currentAnnotation.InstantTaken  = DateTime.Now;
                 currentAnnotation.InstantClosed = null;
             }
             else
             {
                 // if it was active and now it isn't, we set the date closed now
                 currentAnnotation.InstantClosed = DateTime.Now;
             }
         }
         if (SaveMany)
         {
             foreach (Student s in chosenStudents)
             {
                 db.SaveAnnotation(currentAnnotation, s);
             }
         }
         else
         {
             db.SaveAnnotation(currentAnnotation, currentStudent);
         }
     }
     RefreshUI();
 }