private void CityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (CityComboBox.SelectedItem != null) { Id_City = CityService.GetCity() .Where(x => (x.Name == CityComboBox.SelectedItem.ToString())) .Select(x => x.Id).FirstOrDefault(); cityName = CitySetName.Text = CityService.GetCity() .Where(x => (x.Name == CityComboBox.SelectedItem.ToString())) .Select(x => x.Name).FirstOrDefault().ToString(); cityPopulation = CitySetPopulation.Text = CityService.GetCity() .Where(x => (x.Name == CityComboBox.SelectedItem.ToString())) .Select(x => x.Population).FirstOrDefault().ToString(); PlaceComboBoxList(); BuildingComboBoxList(); PlaceSetStreet.Clear(); PlaceSetPopulation.Clear(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); } }
private void CountryComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (CountryComboBox.SelectedItem != null) { Id_Country = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Id).FirstOrDefault(); countryName = CountrySetName.Text = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Name).FirstOrDefault().ToString(); countryContinent = CountrySetContinent.Text = CountryService.GetCountry() .Where(x => (x.Name == CountryComboBox.SelectedItem.ToString())) .Select(x => x.Continent).FirstOrDefault().ToString(); PresidentComboBoxList(); CityComboBoxList(); PlaceComboBoxList(); BuildingComboBoxList(); PresidentSetName.Clear(); PresidentSetAge.Clear(); CitySetName.Clear(); CitySetPopulation.Clear(); PlaceSetStreet.Clear(); PlaceSetPopulation.Clear(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); } }
private void PlaceComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (PlaceComboBox.SelectedItem != null) { Place_Id = PlaceService.GetPlace() .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString())) .Select(x => x.Id).FirstOrDefault(); Place_Id_Building = PlaceService.GetPlace() .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString())) .Select(x => x.BuildingModel.Id).FirstOrDefault(); placeStreet = PlaceSetStreet.Text = PlaceService.GetPlace() .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString())) .Select(x => x.Street).FirstOrDefault().ToString(); placePopulation = PlaceSetPopulation.Text = PlaceService.GetPlace() .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString())) .Select(x => x.PlacePopulation).FirstOrDefault().ToString(); BuildingComboBoxList(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); } }
private void Delete_Click(object sender, RoutedEventArgs e) { if (Id_Country != 0) { DeleteService.DeleteAllCoutry(Id_Country); } CountryComboBoxList(); PresidentComboBoxList(); CityComboBoxList(); PlaceComboBoxList(); BuildingComboBoxList(); CountrySetName.Clear(); CountrySetContinent.Clear(); PresidentSetName.Clear(); PresidentSetAge.Clear(); CitySetName.Clear(); CitySetPopulation.Clear(); PlaceSetStreet.Clear(); PlaceSetPopulation.Clear(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); }
private void Save_Click(object sender, RoutedEventArgs e) { string _countryName = CountrySetName.Text; string _countryContinent = CountrySetContinent.Text; string _presidentName = PresidentSetName.Text; int _presidentAge; bool _presidentAgeBool = Int32.TryParse(PresidentSetAge.Text, out _presidentAge); string _cityName = CitySetName.Text; int _cityPopulation; bool _cityPopulationBool = Int32.TryParse(CitySetPopulation.Text, out _cityPopulation); string _placeStreet = PlaceSetStreet.Text; int _placePopulation; bool _placePopulationBool = Int32.TryParse(PlaceSetPopulation.Text, out _placePopulation); string _buildingType = BuildingSetType.Text; string _buildingWindows = BuildingSetWindows.Text; string _buildingIndustrial = BuildingSetIsIndustrial.Text; bool _buildingWindowsBool; bool _buildingIndustrialBool; if (_buildingWindows.ToUpper().Trim() == "TAK") { _buildingWindowsBool = true; } else { _buildingWindowsBool = false; } if (_buildingIndustrial.ToUpper().Trim() == "TAK") { _buildingIndustrialBool = true; } else { _buildingIndustrialBool = false; } if (_countryName == "" || _presidentName == "") { MessageBox.Show("Nie została podana nazwa państwa lub/i nazwisko prezydenta"); return; } if (!_presidentAgeBool || !_cityPopulationBool || !_placePopulationBool) { MessageBox.Show("Wartości dla wieku czy populacji należy podawać w liczbach całkowitych"); return; } if (_countryName == countryName) { if (_countryContinent != countryContinent) { CountryService.SaveCountry(_countryName, _countryContinent, Id_Country); } if (_cityName == cityName && _cityPopulation != Convert.ToInt32(cityPopulation)) { CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country, Id_City); } if (_cityName != cityName) { CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country); Id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault(); } if ((_buildingType == buildingType && (_buildingWindows != buildingWindows || _buildingIndustrial != buildingIndustrial))) { BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool, Place_Id_Building); } if (_buildingType != buildingType) { BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool); Place_Id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault(); } if (_placeStreet == placeStreet && _placePopulation != Convert.ToInt32(placePopulation)) { PlaceService.SavePlace(_placeStreet, _placePopulation, Id_City, Place_Id_Building, Place_Id); } if (_placeStreet != placeStreet) { PlaceService.SavePlace(_placeStreet, _placePopulation, Id_City, Place_Id_Building); } } else { CountryService.SaveCountry(_countryName, _countryContinent); int id_Country = CountryService.GetCountry().Select(x => x.Id).LastOrDefault(); PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), id_Country); CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), id_Country); int id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault(); BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool); Place_Id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault(); PlaceService.SavePlace(_placeStreet, Convert.ToInt32(_placePopulation), id_City, Place_Id_Building); } CountryComboBoxList(); PresidentComboBoxList(); CityComboBoxList(); PlaceComboBoxList(); BuildingComboBoxList(); CountrySetName.Clear(); CountrySetContinent.Clear(); PresidentSetName.Clear(); PresidentSetAge.Clear(); CitySetName.Clear(); CitySetPopulation.Clear(); CitySetPopulation.Clear(); PlaceSetStreet.Clear(); PlaceSetPopulation.Clear(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); }
private void Save_Click(object sender, RoutedEventArgs e) { string _countryName = CountrySetName.Text; string _countryContinent = CountrySetContinent.Text; string _presidentName = PresidentSetName.Text; string _presidentAge = PresidentSetAge.Text; string _cityName = CitySetName.Text; string _cityPopulation = CitySetPopulation.Text; string _palceStreet = PlaceSetStreet.Text; string _placePopulation = PlaceSetPopulation.Text; string _buildingType = BuildingSetType.Text; string _buildingWindows = BuildingSetWindows.Text; string _buildingIndustrial = BuildingSetIsIndustrial.Text; //if(_countryName==""||) if ((_countryName == countryName && _countryContinent != countryContinent) || (_countryName == countryName && _countryContinent == countryContinent)) { CountryService.SaveCountry(_countryName, _countryContinent, Id_Country); //bez sensu. nawet jak nie zmieniam country to męczy DB i updatuje if ((_presidentName == presidentName && _presidentAge != presidentAge) || _presidentName != presidentName) { PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), Id_Country); } if (_cityName != "") { CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), Id_Country, Id_City); } } if (_countryName != countryName) { bool _buildingWindowsBool; bool _buildingIndustrialBool; CountryService.SaveCountry(_countryName, _countryContinent); int id_Country = CountryService.GetCountry().Select(x => x.Id).LastOrDefault(); PresidentService.SavePresident(_presidentName, Convert.ToInt32(_presidentAge), id_Country); CityService.SaveCity(_cityName, Convert.ToInt32(_cityPopulation), id_Country); int id_City = CityService.GetCity().Select(x => x.Id).LastOrDefault(); if (_buildingWindows.ToUpper().Trim() == "TAK") { _buildingWindowsBool = true; } else { _buildingWindowsBool = false; } if (_buildingIndustrial.ToUpper().Trim() == "TAK") { _buildingIndustrialBool = true; } else { _buildingIndustrialBool = false; } BuildingService.SaveBuilding(_buildingType, _buildingWindowsBool, _buildingIndustrialBool); int id_Building = BuildingService.GetBuilding().Select(x => x.Id).LastOrDefault(); PlaceService.SavePlace(_palceStreet, Convert.ToInt32(_placePopulation), id_City, id_Building); } CountryComboBoxList(); PresidentComboBoxList(); CityComboBoxList(); PlaceComboBoxList(); BuildingComboBoxList(); CountrySetName.Clear(); CountrySetContinent.Clear(); PresidentSetName.Clear(); PresidentSetAge.Clear(); CitySetName.Clear(); CitySetPopulation.Clear(); CitySetPopulation.Clear(); PlaceSetStreet.Clear(); PlaceSetPopulation.Clear(); BuildingSetType.Clear(); BuildingSetWindows.Clear(); BuildingSetIsIndustrial.Clear(); }