public static void DB_Insert_PRESET(PresetSettings aSettings) { using (SqliteConnection db = new SqliteConnection(sqlConnectionFileName)) { db.Open(); String insertPresetCommand = "INSERT INTO " + "SettingsPresetsTable " + "(presetName, sessionTime, " + "shortBreakTime, longBreakTime) " + "VALUES " + "('" + aSettings.GetPresetName() + "', '" + aSettings.GetSessionTime().ToString("mm\\:ss") + "', '" + aSettings.GetShortBreakTime().ToString("mm\\:ss") + "', '" + aSettings.GetLongBreakTime().ToString("mm\\:ss") + "')"; using (SqliteCommand insertPreset = new SqliteCommand(insertPresetCommand, db)) { try { insertPreset.ExecuteNonQuery(); } catch (Exception e) { //Sql Exception. Preset already exists... db.Close(); } } db.Close(); } }
public static void DB_UPDATE_PRESET(PresetSettings aSettings) { using (SqliteConnection db = new SqliteConnection(sqlConnectionFileName)) { db.Open(); String updatePresetCommand = "UPDATE SettingsPresetsTable " + "SET sessionTime = '" + aSettings.GetSessionTime().ToString("mm\\:ss") + "', " + "shortBreakTime = '" + aSettings.GetShortBreakTime().ToString("mm\\:ss") + "', " + "longBReakTime = '" + aSettings.GetLongBreakTime().ToString("mm\\:ss") + "' " + "WHERE presetName = '" + aSettings.GetPresetName() + "' "; using (SqliteCommand updatePreset = new SqliteCommand(updatePresetCommand, db)) { updatePreset.ExecuteNonQuery(); } db.Close(); } }