Пример #1
0
        private void editCarButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Add_Car_n add = new Add_Car_n();
                add.Owner = this;
                editFlag  = true;

                using (UserContext db = new UserContext())
                {
                    if (db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Id == 1)
                    {
                        throw new Exception("Выберите автомобиль");
                    }

                    add.nameTextbox.Text                 = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Name;
                    add.modelTextbox.Text                = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Model;
                    add.engineVolumeTextbox.Text         = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].EngineVolume.ToString();
                    add.dateOfReleasePicker.SelectedDate = Convert.ToDateTime(db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].ReleaseDate);
                    add.categoryCombobox.Text            = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Category;
                    add.colorTextbox.Text                = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Color;
                    add.mileageTextbox.Text              = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Mileage.ToString();
                    add.priceTextbox.Text                = db.Cars.ToList()[carsDatagrid.SelectedIndex + 1].Price.ToString();
                }

                add.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        //////////////////////////////////////////////CARS/////////////////////////////////////////////////

        private void addCarButton_Click(object sender, RoutedEventArgs e)
        {
            Add_Car_n add = new Add_Car_n();

            add.Owner = this;
            add.Show();
        }