private void Btn_Accept(object sender, RoutedEventArgs e) { _addedCar.Manufacturer = textBoxManufacturer.Text; _addedCar.Model = textBoxModel.Text; _addedCar.Year = int.Parse(textBoxYear.Text); _addedCar.Fault = textBoxFault.Text; _addedCar.ArrivalDate = (DateTime)ArrivalDatePicker.SelectedDate; _addedCar.DepartureDate = (DateTime)DepartureDatePicker.SelectedDate; _addedCar.OwnerId = comboBoxOwner.SelectedIndex; _addedCar.ServiceID = comboBoxService.SelectedIndex; _addedCar.EmployeeID = comboBoxEmployee.SelectedIndex; CarRepository.AddElement(_addedCar); //CarsView.Ref this.Close(); }