Пример #1
0
 private void LoadEvidenceForHotThought(int id, SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         EvidenceForHotThought forHot = new EvidenceForHotThought();
         string commandText           = "SELECT [EvidenceForHotThoughtID], [AutomaticThoughtsID], [Evidence] FROM EvidenceForHotThought WHERE [ThoughtRecordID] = " + id;
         if (sqLiteDatabase.IsOpen)
         {
             var data = sqLiteDatabase.RawQuery(commandText, null);
             if (data != null)
             {
                 if (data.MoveToNext())
                 {
                     do
                     {
                         forHot = new EvidenceForHotThought();
                         forHot.EvidenceForHotThoughtId = data.GetInt(0);
                         forHot.ThoughtRecordId         = id;
                         forHot.AutomaticThoughtsId     = data.GetInt(1);
                         forHot.Evidence = data.GetString(2).Trim();
                         forHot.IsNew    = false;
                         forHot.IsDirty  = false;
                         EvidenceForHotThoughtList.Add(forHot);
                     }while (data.MoveToNext());
                 }
             }
             data.Close();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Load of Evidence for Hot Thought failed - " + e.Message);
     }
 }
Пример #2
0
 public void RemoveEvidenceForHotThought(EvidenceForHotThought evidenceForHotThought)
 {
     try
     {
         if (evidenceForHotThought != null)
         {
             EvidenceForHotThoughtList.Remove(evidenceForHotThought);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to remove Evidence for Hot Thought failed - " + e.Message);
     }
 }
Пример #3
0
 public void AddEvidenceForHotThought(EvidenceForHotThought newEvidenceForHotThought)
 {
     try
     {
         if (newEvidenceForHotThought != null)
         {
             EvidenceForHotThoughtList.Add(newEvidenceForHotThought);
             IsDirty = true;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to add Evidence for Hot Thought failed - " + e.Message);
     }
 }
Пример #4
0
 private void ClearEvidenceForHotThought(SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         if (EvidenceForHotThoughtList.Count > 0)
         {
             foreach (var evidenceForHotThought in EvidenceForHotThoughtList)
             {
                 if (!evidenceForHotThought.IsNew)
                 {
                     evidenceForHotThought.Remove(sqLiteDatabase);
                 }
             }
             EvidenceForHotThoughtList.Clear();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to clear Evidence for Hot Thoughts failed - " + e.Message);
     }
 }
Пример #5
0
        public void RemoveAutomaticThought(AutomaticThoughts automaticThought, SQLiteDatabase sqlDatabase)
        {
            try
            {
                //caller will have to warn User that any EvidenceForHotThought and EvidenceAgainstHotThought based on this will also be removed
                if (automaticThought != null)
                {
                    //find and remove any EvidenceForHotThought with this ID
                    foreach (var evidenceForHotThought in EvidenceForHotThoughtList)
                    {
                        if (evidenceForHotThought.AutomaticThoughtsId == automaticThought.AutomaticThoughtsId)
                        {
                            EvidenceForHotThoughtList.Remove(evidenceForHotThought);
                            evidenceForHotThought.Remove(sqlDatabase);
                            break;
                        }
                    }
                    //find and remove any EvidenceAgainstHotThought with this ID
                    foreach (var evidenceAgainstHotThought in EvidenceAgainstHotThoughtList)
                    {
                        if (evidenceAgainstHotThought.AutomaticThoughtsId == automaticThought.AutomaticThoughtsId)
                        {
                            EvidenceAgainstHotThoughtList.Remove(evidenceAgainstHotThought);
                            evidenceAgainstHotThought.Remove(sqlDatabase);
                            break;
                        }
                    }

                    automaticThought.Remove(sqlDatabase);
                    AutomaticThoughtsList.Remove(automaticThought);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Attempt to remove Automatic Thought failed - " + e.Message);
            }
        }