Exemple #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbCountry.Text))
            {
                MessageBox.Show("Название страны не должно быть пустым.", "Проверка");
                return;
            }
            if (tbCountry.Text.Length > 30)
            {
                MessageBox.Show("Слишком длинное слово.", "Проверка");
                return;
            }

            if ((!string.IsNullOrEmpty(tbCountry.Text)))
            {
                CountryDto countr = new CountryDto();
                countr.NameCountry = tbCountry.Text;
                ICountryProcess workProcess = ProcessFactory.GetCountryProcess();
                if (_id == 0)
                {
                    workProcess.Add(countr);
                }
                else
                {
                    countr.IDCountry = _id;
                    workProcess.Add(countr);
                }

                Close();
            }
        }
        private void btnAddC_Click(object sender, RoutedEventArgs e)
        {
            WinCountry window = new WinCountry();

            window.ShowDialog();

            dgCountry.ItemsSource = ProcessFactory.GetCountryProcess().GetList();
        }
        private void btnDeleteC_Click(object sender, RoutedEventArgs e)
        {
            CountryDto item = dgCountry.SelectedItem as CountryDto;

            if (item == null)
            {
                MessageBox.Show("Выберите запись для удаления", "Удаление страны");
                return;
            }

            MessageBoxResult result = MessageBox.Show("Удалить " + item.NameCountry + "?", "Удаление страны", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            ProcessFactory.GetCountryProcess().Delete(item.IDCountry);

            btnUpdateC_Click(sender, e);
        }
 private void btnUpdateC_Click(object sender, RoutedEventArgs e)
 {
     dgCountry.ItemsSource = ProcessFactory.GetCountryProcess().GetList();
 }