private void Save_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(City_TextBox.Text) || string.IsNullOrEmpty(Population_TextBox.Text)) { MessageBox.Show("Input values"); return; } double population; if (!double.TryParse(Population_TextBox.Text, out population)) { MessageBox.Show("Invalid input"); return; } City city = new City(City_TextBox.Text, population); if (isNewData) { InsertCity(city); } else { DBSQLite.GetInstance().UpdateCity(originCity, city); Close(); } }
//inserting new record private void InsertCity(City city) { bool isAdded = DBSQLite.GetInstance().AddCity(city); if (isAdded) { Close(); } }
//creating list of data from database with radiobuttons private void LoadCities() { DataBase_ListBox.Items.Clear(); List <City> cities = DBSQLite.GetInstance().FetchCities(); foreach (var city in cities) { //using custom radiobutton CityRadioButton cityRadioButton = new CityRadioButton(city); cityRadioButton.Click += CityRadioButton_Click; DataBase_ListBox.Items.Add(cityRadioButton); } }
private void Delete_Click(object sender, RoutedEventArgs e) { DBSQLite.GetInstance().DeleteCity(selectedCity); ReloadCitiesData(); }
private void PrepareHighestPopulation() { City city = DBSQLite.GetInstance().FetchMostPopulatedCity(); HighestPopulation_Label.Content = "Highest population n " + city.Name + " - " + String.Format("{0:n}", city.Population); }
private void PrepareTotalPopulation() { double totalPopulation = DBSQLite.GetInstance().FetchTotalPopulation(); TotalPopulation_Label.Content = "Total population:\t" + String.Format("{0:n}", totalPopulation); }