コード例 #1
0
ファイル: Task4.cs プロジェクト: bodik16/ITEA
 private void AddCountryButtonFinally_Click(object sender, EventArgs e)
 {
     CreateCountries(CountryNameTextBox, CountryPopulationTExtBox, InfLabel4, CountriescheckedListBox1);
     NameLabel.Visible       = false;
     PopulationLabel.Visible = false;
     CountryPopulationTExtBox.Clear();
     CountryPopulationTExtBox.Visible = false;
     CountryNameTextBox.Clear();
     CountryNameTextBox.Visible = false;
     CalculateAveragePopulationFromTheList(ListOfCountries.Countries, label4, AveragePopulationLabelEveryCountriesFromList, InfLabel4);
 }
コード例 #2
0
        private void AddCountryButton_Click(object sender, EventArgs e)
        {
            //make the country code empty
            CountryCodeTextBox.Text = string.Empty;

            //clear any value in the name textbox
            CountryNameTextBox.Text = string.Empty;

            //clear the selection in the listbox
            CountryListBox.SelectedIndex = -1;

            CountryNameTextBox.Focus();
        }
コード例 #3
0
        private void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            CountryName         = (System.Windows.Controls.TextBox) this.FindName("CountryNameTextBox");
            CountryPath         = (System.Windows.Controls.TextBox) this.FindName("CountryPathTextBox");
            CountryAbbreviation = (System.Windows.Controls.TextBox) this.FindName("CountryAbbreviationTextBox");
            Languages           = (System.Windows.Controls.ComboBox) this.FindName("LanguageComboBox");
            NextButton          = (System.Windows.Controls.Button) this.FindName("NextButton");

            if (ValidateForm(CountryName.Text, CountryPath.Text, CountryAbbreviation.Text))
            {
                var         selectedTag        = ((ComboBoxItem)Languages.SelectedItem).Tag.ToString();
                var         selectedName       = ((ComboBoxItem)Languages.SelectedItem).Content.ToString();
                CultureInfo defaultCultureInfo = new CultureInfo(selectedTag);

                Guid countryId = ImportSQL.ImportCountryAndDefaultLanguage(_connectionString,
                                                                           new CountryLanguageModel
                {
                    CountryAbbreviation = CountryAbbreviation.Text,
                    CountryName         = CountryName.Text,
                    CountryPath         = CountryPath.Text,
                    LanguageName        = selectedName,
                    LanguageShortName   = selectedName,
                    LCID = defaultCultureInfo.LCID
                }
                                                                           );

                if (countryId != null && countryId != Guid.Empty)
                {
                    NextButton.IsEnabled = true;
                    CountryIds.Add(countryId);

                    CountryNameTextBox.Clear();
                    CountryPathTextBox.Clear();
                    CountryAbbreviationTextBox.Clear();

                    MessageBox.Show("Success!");
                }
                else
                {
                    MessageBox.Show("Country import was not succesfull.");
                }
            }
        }