Beispiel #1
0
        public void Remove()
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    var sql = "DELETE FROM [Imagery] WHERE ImageryID = " + ImageryID.ToString();
                    sqlDatabase.ExecSQL(sql);
                    Log.Info(TAG, "Remove: Removed Image with ID " + ImageryID.ToString() + " successfully");
                    sqlDatabase.Close();
                }
                Log.Error(TAG, "Remove: SQLite database is null or was not opened - remove failed");
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Remove: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
            }
        }
Beispiel #2
0
        public void Save()
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null)
                {
                    if (sqlDatabase.IsOpen)
                    {
                        ContentValues values = new ContentValues();
                        values.Put("ImageryURI", ImageryURI.Trim());
                        values.Put("ImageryComment", ImageryComment.Trim());
                        if (IsNew)
                        {
                            ImageryID = (int)sqlDatabase.Insert("Imagery", null, values);
                            IsNew     = false;
                            IsDirty   = false;
                        }
                        if (IsDirty)
                        {
                            string whereClause = "ImageryID = ?";
                            sqlDatabase.Update("Imagery", values, whereClause, new string[] { ImageryID.ToString() });
                            IsDirty = false;
                        }
                        sqlDatabase.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Save: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
            }
        }