Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        //inserting new record
        private void InsertCity(City city)
        {
            bool isAdded = DBSQLite.GetInstance().AddCity(city);

            if (isAdded)
            {
                Close();
            }
        }
Exemplo n.º 3
0
        //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);
            }
        }
Exemplo n.º 4
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     DBSQLite.GetInstance().DeleteCity(selectedCity);
     ReloadCitiesData();
 }
Exemplo n.º 5
0
        private void PrepareHighestPopulation()
        {
            City city = DBSQLite.GetInstance().FetchMostPopulatedCity();

            HighestPopulation_Label.Content = "Highest population n " + city.Name + " - " + String.Format("{0:n}", city.Population);
        }
Exemplo n.º 6
0
        private void PrepareTotalPopulation()
        {
            double totalPopulation = DBSQLite.GetInstance().FetchTotalPopulation();

            TotalPopulation_Label.Content = "Total population:\t" + String.Format("{0:n}", totalPopulation);
        }