Example #1
0
 /// <summary>
 /// This method is used to sync bf records between datasets
 /// It only works after the bf has been saved and committed
 /// </summary>
 /// <param name="abfr"></param>
 public void SyncAppointment(atriumDB.AppointmentRow apptRow, bool forDelete)
 {
     //see if bf is loaded
     atriumDB.AppointmentRow apptRowToSync = DB.Appointment.FindByApptId(apptRow.ApptId);
     if (apptRowToSync != null)
     {
         if (apptRowToSync.RowState == DataRowState.Unchanged)
         {
             if (forDelete)
             {
                 try
                 {
                     apptRowToSync.Delete();
                 }
                 catch (Exception x)
                 {
                     apptRowToSync.RowError = "";
                 }
                 apptRowToSync.AcceptChanges();
             }
             else
             {
                 //if it is sync it
                 GetAppointment().Load(apptRow.ApptId);
                 if (IsVirtualFM && apptRowToSync.GetAttendeeRows().Length > apptRow.GetAttendeeRows().Length)
                 {
                     //an attendee must have been deleted
                     foreach (atriumDB.AttendeeRow atrd in apptRowToSync.GetAttendeeRows())
                     {
                         atrd.Delete();
                     }
                     DB.Attendee.AcceptChanges();
                 }
                 GetAttendee().LoadByApptId(apptRow.ApptId);
                 if (apptRow.OriginalRecurrence)
                 {
                     GetApptRecurrence().Load(apptRow.ApptRecurrenceId);
                 }
             }
         }
     }
     else
     {
         //load it
         atriumDB.AppointmentRow appr = (atriumDB.AppointmentRow)GetAppointment().Load(apptRow.ApptId);
         GetAttendee().LoadByApptId(appr.ApptId);
         if (appr.OriginalRecurrence)
         {
             GetApptRecurrence().Load(appr.ApptRecurrenceId);
         }
         //check to see if bflistofficer is an attendee
         atriumDB.AttendeeRow[] attrs = (atriumDB.AttendeeRow[])DB.Attendee.Select("ApptId=" + appr.ApptId.ToString() + " and ContactId=" + BfListOfficerId.ToString());
         if (attrs.Length > 0)
         {
             //ok 2 keep
         }
         else
         {
             try
             {
                 appr.Delete();
             }
             catch (Exception x)
             {
                 //do nothing
                 appr.RowError = "";
             }
             appr.AcceptChanges();
         }
     }
 }