private void AddDriver_Click(object sender, RoutedEventArgs e) { try { DriverModel newDriver = new DriverModel() { FirstName = FirstName.Text, LastName = LastName.Text, Patronymic = Patronymic.Text, SerialPasp = PaspSeries.Text, NumberPasp = PaspNumber.Text, DateBirth = DateBirth.SelectedDate.Value, FullAddressLife = CityLife.Text + " " + AddressLife.Text, FullAddress = City.Text + " " + AddressLife.Text, Telephone = Phone.Text, DrivingExperience = int.Parse(Expirience.Text), PostCode = int.Parse(PostCode.Text), Company = Company.Text, JobName = JobName.Text, Email = Email.Text }; if (ImageURL.Text == "") { newDriver.Photo = null; } else { newDriver.Photo = ImageLogic.ByteFromImage(ImageURL.Text); } DriverLogic.AddDriver(newDriver); MessageBox.Show("Водитель успешно добавлен!"); switch (SecurityContext.CurrentWindow) { case Logic.Enums.EnumWindow.AddLicense: this.Close(); break; case Logic.Enums.EnumWindow.AddTransport: this.Close(); break; case Logic.Enums.EnumWindow.DriverList: DriverList driverList = new DriverList(); driverList.Show(); this.Close(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }