private void ChangeDriver_Click(object sender, RoutedEventArgs e) { try { if (Name.Text.Where(nam => nam == ' ').Count() == 2) { string[] NameArray = new string[2]; NameArray = Name.Text.Split(' '); DriverModel driver = new DriverModel { FirstName = NameArray[0], LastName = NameArray[1], Patronymic = NameArray[2], Telephone = Phone.Text, Email = Mail.Text, SerialPasp = Passport.Text.Substring(0, 4), NumberPasp = Passport.Text.Substring(4, 6), DateBirth = DateBirth.SelectedDate.Value, DrivingExperience = int.Parse(Expirience.Text), FullAddressLife = AddressLife.Text, FullAddress = Address.Text, PostCode = int.Parse(PostCode.Text), Company = Company.Text, JobName = JobName.Text, }; if (PhotoURL.Text != "") { driver.Photo = File.ReadAllBytes(PhotoURL.Text); } else { driver.Photo = Currentdriver.Photo; } DriverLogic.ChangeDriver(driver); MessageBox.Show("Водитель успешно изменен!"); DriverList driverList = new DriverList(); driverList.Show(); this.Close(); } else { throw new Exception("ФИО введен не верно!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }