public void Save(SQLiteDatabase sqLiteDatabase) { if (sqLiteDatabase.IsOpen) { if (IsNew) { try { string[] columns = { "CountryName", "PoliceNumber", "AmbulanceNumber", "FireNumber", "Notes" }; ContentValues values = new ContentValues(); values.Put("CountryName", CountryName.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("PoliceNumber", PoliceNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("AmbulanceNumber", AmbulanceNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("FireNumber", FireNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("Notes", Notes.Trim().Replace("'", "''").Replace("\"", "\"\"")); EmergencyNumberID = (int)sqLiteDatabase.Insert("EmergencyNumbers", null, values); IsNew = false; IsDirty = false; } catch (Exception newE) { throw new Exception("Unable to Save EmergencyNumber in database - " + newE.Message); } } if (IsDirty) { try { ContentValues values = new ContentValues(); values.Put("CountryName", CountryName.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("PoliceNumber", PoliceNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("AmbulanceNumber", AmbulanceNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("FireNumber", FireNumber.Trim().Replace("'", "''").Replace("\"", "\"\"")); values.Put("Notes", Notes.Trim().Replace("'", "''").Replace("\"", "\"\"")); string whereClause = "EmergencyNumberID = " + EmergencyNumberID; sqLiteDatabase.Update("EmergencyNumbers", values, whereClause, null); IsDirty = false; } catch (Exception dirtyE) { throw new Exception("Unable to Update Emergency Number in database - " + dirtyE.Message); } } } }
public bool IsValid() { bool result = true; if (FirstName.Trim().Length < 1) { result = false; } if (LastName.Trim().Length < 1) { result = false; } if (Line1.Trim().Length < 1) { result = false; } if (CountryBvin.Trim().Length < 1) { result = false; } if (CountryName.Trim().Length < 1) { result = false; } if (CountryBvin == "bf7389a2-9b21-4d33-b276-23c9c18ea0c0") { if (RegionBvin.Trim().Length < 1) { if (RegionName.Trim().Length < 1) { result = false; } } } if (_PostalCode.Trim().Length < 1) { result = false; } return(result); }
public string toString() { return(CountryName.Trim() + ", Police: " + PoliceNumber.Trim() + ", Ambulance: " + AmbulanceNumber.Trim() + ", Fire: " + FireNumber.Trim()); }