public string toString() { string ret = ""; ret = Thought.Trim() + (IsHotThought ? " - HOT THOUGHT" : ""); return(ret); }
public void Save(SQLiteDatabase sqLiteDatabase) { if (sqLiteDatabase.IsOpen) { if (IsNew) { try { ContentValues values = new ContentValues(); values.Put("ThoughtRecordID", ThoughtRecordId); values.Put("Thought", Thought.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("HotThought", IsHotThought?1:0); AutomaticThoughtsId = (int)sqLiteDatabase.Insert("AutomaticThoughts", null, values); IsNew = false; IsDirty = false; } catch (Exception newE) { throw new Exception("Unable to Save Automatic Thought in database - " + newE.Message); } } if (IsDirty) { try { String whereClause = "AutomaticThoughtsID = " + AutomaticThoughtsId; IsDirty = false; ContentValues values = new ContentValues(); values.Put("ThoughtRecordID", ThoughtRecordId); values.Put("Thought", Thought.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("HotThought", IsHotThought ? 1 : 0); sqLiteDatabase.Update("AlternativeThoughts", values, whereClause, null); } catch (Exception dirtyE) { throw new Exception("Unable to Update Automatic Thought in database - " + dirtyE.Message); } } } }