예제 #1
0
 public static void UpdateSettings(SettingsDataModel settings)
 {
     using (SQLiteConnection connection = DatabaseUtility.GetNewConnection())
     using (SQLiteCommand updateCommand = connection.CreateCommand())
     {
         updateCommand.CommandText = "UPDATE Settings SET recipeSize = @recipeSize, boilTime = @boilTime, extractionEfficiency = @extractionEfficiency, yeastWeight = @yeastWeight, hopsAmount = @hopsAmount WHERE id = @id";
         updateCommand.Parameters.AddWithValue("id", settings.SettingsId);
         updateCommand.Parameters.AddWithValue("recipeSize", settings.RecipeSize);
         updateCommand.Parameters.AddWithValue("boilTime", settings.BoilTime);
         updateCommand.Parameters.AddWithValue("extractionEfficiency", settings.ExtractionEfficiency);
         updateCommand.Parameters.AddWithValue("yeastWeight", settings.YeastWeight);
         updateCommand.Parameters.AddWithValue("hopsAmount", settings.HopsAmount);
         updateCommand.ExecuteNonQuery();
     }
 }
예제 #2
0
        public static SettingsDataModel GetSavedSettings()
        {
            SettingsDataModel settings;

            using (SQLiteConnection connection = DatabaseUtility.GetNewConnection())
            using (SQLiteCommand selectCommand = connection.CreateCommand())
            {
                selectCommand.CommandText = "SELECT * FROM Settings LIMIT 1";
                using (SQLiteDataReader reader = selectCommand.ExecuteReader())
                {
                    reader.Read();
                    settings = new SettingsDataModel(reader.GetInt32(0));
                    settings.RecipeSize = reader.GetFloat(1);
                    settings.BoilTime = reader.GetInt32(2);
                    settings.ExtractionEfficiency = reader.GetFloat(3);
                    settings.YeastWeight = reader.GetFloat(4);
                    settings.HopsAmount = reader.GetFloat(5);
                }
            }
            return settings;
        }
예제 #3
0
 public void GetSettings()
 {
     m_settings = SettingsUtility.GetSavedSettings();
     foreach (RecipeDataModel recipe in m_savedRecipes)
         recipe.ExtractionEfficiency = m_settings.ExtractionEfficiency;
 }
예제 #4
0
 public SettingsViewModel()
 {
     m_settings = SettingsUtility.GetSavedSettings();
     m_settings.PropertyChanged += Setting_PropertyChanged;
 }