示例#1
0
 private void LoadAlternativeThoughts(int id, SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         AlternativeThoughts altThought = new AlternativeThoughts();
         string commandText             = "SELECT [AlternativeThoughtsID], [Alternative], [BeliefRating] FROM AlternativeThoughts WHERE [ThoughtRecordID] = " + id;
         if (sqLiteDatabase.IsOpen)
         {
             var data = sqLiteDatabase.RawQuery(commandText, null);
             if (data != null)
             {
                 if (data.MoveToNext())
                 {
                     do
                     {
                         altThought = new AlternativeThoughts();
                         altThought.AlternativeThoughtsId = data.GetInt(0);
                         altThought.ThoughtRecordId       = id;
                         altThought.Alternative           = data.GetString(1).Trim();
                         altThought.BeliefRating          = data.GetInt(2);
                         altThought.IsNew   = false;
                         altThought.IsDirty = false;
                         AlternativeThoughtsList.Add(altThought);
                     }while (data.MoveToNext());
                 }
             }
             data.Close();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Load of Alternative Thoughts failed - " + e.Message);
     }
 }
示例#2
0
 public void RemoveAlternative(AlternativeThoughts alternativeThought)
 {
     try
     {
         if (alternativeThought != null)
         {
             AlternativeThoughtsList.Remove(alternativeThought);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to remove Alternative Thought failed - " + e.Message);
     }
 }
示例#3
0
 public void AddAlternativeThought(AlternativeThoughts newAlternativeThought)
 {
     try
     {
         if (newAlternativeThought != null)
         {
             AlternativeThoughtsList.Add(newAlternativeThought);
             IsDirty = true;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to add Alternative Thought failed - " + e.Message);
     }
 }
示例#4
0
 private void ClearAlternativeThoughts(SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         if (AlternativeThoughtsList.Count > 0)
         {
             foreach (var alternativeThought in AlternativeThoughtsList)
             {
                 if (!alternativeThought.IsNew)
                 {
                     alternativeThought.Remove(sqLiteDatabase);
                 }
             }
             AlternativeThoughtsList.Clear();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to clear Alternative Thoughts failed - " + e.Message);
     }
 }