Exemplo n.º 1
0
 private void LoadEvidenceAgainstHotThought(int id, SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         EvidenceAgainstHotThought againstHot = new EvidenceAgainstHotThought();
         string commandText = "SELECT [EvidenceAgainstHotThoughtID], [AutomaticThoughtsID], [Evidence] FROM EvidenceAgainstHotThought WHERE [ThoughtRecordID] = " + id;
         if (sqLiteDatabase.IsOpen)
         {
             var data = sqLiteDatabase.RawQuery(commandText, null);
             if (data != null)
             {
                 if (data.MoveToNext())
                 {
                     do
                     {
                         againstHot = new EvidenceAgainstHotThought();
                         againstHot.EvidenceAgainstHotThoughtId = data.GetInt(0);
                         againstHot.ThoughtRecordId             = id;
                         againstHot.AutomaticThoughtsId         = data.GetInt(1);
                         againstHot.Evidence = data.GetString(2).Trim();
                         againstHot.IsNew    = false;
                         againstHot.IsDirty  = false;
                         EvidenceAgainstHotThoughtList.Add(againstHot);
                     }while (data.MoveToNext());
                 }
             }
             data.Close();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Load of Evidence against Hot Thought failed - " + e.Message);
     }
 }
Exemplo n.º 2
0
 public void RemoveEvidenceAgainstHotThought(EvidenceAgainstHotThought evidenceAgainstHotThought)
 {
     try
     {
         if (evidenceAgainstHotThought != null)
         {
             EvidenceAgainstHotThoughtList.Remove(evidenceAgainstHotThought);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to remove Evidence against Hot Thought failed - " + e.Message);
     }
 }
Exemplo n.º 3
0
 public void AddEvidenceAgainstHotThought(EvidenceAgainstHotThought newEvidenceAgainstHotThought)
 {
     try
     {
         if (newEvidenceAgainstHotThought != null)
         {
             EvidenceAgainstHotThoughtList.Add(newEvidenceAgainstHotThought);
             IsDirty = true;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to add Evidence Against Hot Thought failed - " + e.Message);
     }
 }
Exemplo n.º 4
0
 private void ClearEvidenceAgainstHotThought(SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         if (EvidenceAgainstHotThoughtList.Count > 0)
         {
             foreach (var evidenceAgainstHotThought in EvidenceAgainstHotThoughtList)
             {
                 if (!evidenceAgainstHotThought.IsNew)
                 {
                     evidenceAgainstHotThought.Remove(sqLiteDatabase);
                 }
             }
             EvidenceAgainstHotThoughtList.Clear();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to clear Evidence against Hot Thoughts failed - " + e.Message);
     }
 }
Exemplo n.º 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);
            }
        }