public void Save(SQLiteDatabase sqLiteDatabase) { if (sqLiteDatabase.IsOpen) { if (IsNew) { try { ContentValues values = new ContentValues(); values.Put("CalmMyself", CalmMyself.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("TellMyself", TellMyself.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("WillCall", WillCall.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("WillGoTo", WillGoTo.Trim().Replace("'", "''").Replace("\"", "\"\"")); ID = (int)sqLiteDatabase.Insert("SafetyPlanCards", null, values); Log.Info(TAG, "Save: Saved to database successfully with an ID of " + ID.ToString()); IsNew = false; IsDirty = false; } catch (Exception newE) { Log.Error(TAG, "Save: Exception - " + newE.Message); throw new Exception("Unable to Save Safety Plan Card - " + newE.Message); } } if (IsDirty) { try { string whereClause = "ID = " + ID; ContentValues values = new ContentValues(); values.Put("CalmMyself", CalmMyself.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("TellMyself", TellMyself.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("WillCall", WillCall.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("WillGoTo", WillGoTo.Trim().Replace("'", "''").Replace("\"", "\"\"")); sqLiteDatabase.Update("SafetyPlanCards", values, whereClause, null); IsDirty = false; } catch (SQLException dirtyE) { Log.Error(TAG, "Save: Exception - " + dirtyE.Message); throw new Exception("Unable to Update Safety Plan Card - " + dirtyE.Message); } } } }
protected override void ProcessAdditionalFields(ref Entity record) { if (record == null) { throw new ArgumentNullException(nameof(record)); } record["salesrepid"] = SalesRepId.Get(Context.ExecutionContext); record["shipto_city"] = ShipToCity.Get(Context.ExecutionContext); record["shipto_country"] = ShipToCountry.Get(Context.ExecutionContext); record["shipto_fax"] = ShipToFax.Get(Context.ExecutionContext); record["shipto_line1"] = ShipToLine1.Get(Context.ExecutionContext); record["shipto_line2"] = ShipToLine2.Get(Context.ExecutionContext); record["shipto_line3"] = ShipToLine3.Get(Context.ExecutionContext); record["shipto_name"] = ShipToName.Get(Context.ExecutionContext); record["shipto_postalcode"] = ShipToPostalCode.Get(Context.ExecutionContext); record["shipto_stateorprovince"] = ShipToStateOrProvince.Get(Context.ExecutionContext); record["shipto_telephone"] = ShipToTelephone.Get(Context.ExecutionContext); record["willcall"] = WillCall.Get(Context.ExecutionContext); }