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); } }
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); } }