예제 #1
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndex = dataGridAddAnimals.SelectedIndex;

            if (selectedIndex < 0)
            {
                MessageBox.Show("Не выбрано животное для редактирования");
                return;
            }



            var ap = new DBManager().getSupplierList();

            Models.ModelSupplier modelSupplier = null;
            foreach (var it in ap)
            {
                if (it.Id_Supplier == listSupplier[selectedIndex].Id_Supplier)
                {
                    modelSupplier = it;
                    break;
                }
            }

            var ce = new AddAnimalEditWindow(modelSupplier);

            ce.ShowDialog();
        }
예제 #2
0
        private AddAnimalEditWindow(Models.ModelSupplier modelSupplier)
        {
            InitializeComponent();
            this.modelSupplier = modelSupplier;

            species = (new DBManager()).getSpeciesList();
            ObservableCollection <string> listSpecies = new ObservableCollection <string>();

            foreach (var it in species)
            {
                listSpecies.Add(it.Title);
            }
            this.comboBoxID_Species.ItemsSource = listSpecies;

            if (this.modelSupplier != null)
            {
                int idlistSpecies = -1;
                for (idlistSpecies = 0; idlistSpecies < species.Count; idlistSpecies++)
                {
                    if (species[idlistSpecies].Id_species == this.modelSupplier.Id_Species)
                    {
                        break;
                    }
                }
                comboBoxID_Species.SelectedIndex = idlistSpecies;

                labelID_Model.Content   = this.modelSupplier.Id_Supplier.ToString();
                textBoxReleaseDate.Text = this.modelSupplier.Release_date;
                textBoxTitle.Text       = this.modelSupplier.Title;
            }
            else
            {
                labelID_Model.Content   = string.Empty;
                textBoxReleaseDate.Text = string.Empty;
                textBoxTitle.Text       = string.Empty;
            }
        }