Beispiel #1
0
 private void LoadAutomaticThoughts(int id, SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         AutomaticThoughts autoThought = new AutomaticThoughts();
         string            commandText = "SELECT [AutomaticThoughtsID], [Thought], [HotThought] FROM AutomaticThoughts WHERE [ThoughtRecordID] = " + id;
         if (sqLiteDatabase.IsOpen)
         {
             var data = sqLiteDatabase.RawQuery(commandText, null);
             if (data != null)
             {
                 if (data.MoveToNext())
                 {
                     do
                     {
                         autoThought = new AutomaticThoughts();
                         autoThought.AutomaticThoughtsId = data.GetInt(0);
                         autoThought.ThoughtRecordId     = id;
                         autoThought.Thought             = data.GetString(1).Trim();
                         autoThought.IsHotThought        = Convert.ToBoolean(data.GetShort(2));
                         autoThought.IsNew   = false;
                         autoThought.IsDirty = false;
                         AutomaticThoughtsList.Add(autoThought);
                     }while (data.MoveToNext());
                 }
             }
             data.Close();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Load of Automatic Thoughts failed - " + e.Message);
     }
 }
Beispiel #2
0
 public void AddAutomaticThought(AutomaticThoughts newAutomaticThought)
 {
     try
     {
         if (newAutomaticThought != null)
         {
             AutomaticThoughtsList.Add(newAutomaticThought);
             IsDirty = true;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to add Automatic Thought failed - " + e.Message);
     }
 }