コード例 #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();
            }
        }
コード例 #2
0
ファイル: DB.cs プロジェクト: soibi10/Gr5As10
 public static DBSQLite GetInstance() //singleton
 {
     if (_dbsqlite == null)
     {
         _dbsqlite = new DBSQLite();
     }
     return(_dbsqlite);
 }
コード例 #3
0
        //inserting new record
        private void InsertCity(City city)
        {
            bool isAdded = DBSQLite.GetInstance().AddCity(city);

            if (isAdded)
            {
                Close();
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: soibi10/Gr5As10
        //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);
            }
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: soibi10/Gr5As10
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     DBSQLite.GetInstance().DeleteCity(selectedCity);
     ReloadCitiesData();
 }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: soibi10/Gr5As10
        private void PrepareHighestPopulation()
        {
            City city = DBSQLite.GetInstance().FetchMostPopulatedCity();

            HighestPopulation_Label.Content = "Highest population n " + city.Name + " - " + String.Format("{0:n}", city.Population);
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: soibi10/Gr5As10
        private void PrepareTotalPopulation()
        {
            double totalPopulation = DBSQLite.GetInstance().FetchTotalPopulation();

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