/// Непосредственное редактирование
        private void btn_edit_Click1(object sender, RoutedEventArgs e)
        {
            try
            {
                using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
                {
                    var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == Convert.ToInt64(tb_id.Text));
                    driver.Family     = tb_Family.Text;
                    driver.Name       = tb_name.Text;
                    driver.Patronymic = tb_patronomyc.Text;
                    driver.Phone      = tb_phone.Text;

                    driver.Attorney    = tb_attorney.Text;
                    driver.Auto        = tb_auto.Text;
                    driver.AutoNumber  = tb_autonum.Text;
                    driver.Passport    = tb_passport.Text;
                    driver.Info        = tb_info.Text;
                    driver.ServiceInfo = driver.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " внес изменения";
                    ef.SaveChanges();
                    btn_close_Click(sender, e);
                    ContentAddEdit.Hide();
                    //btn_refresh_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
                ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
            }
        }
        /// Кнопка удалить
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == Convert.ToInt32(tb_id.Text));
                if (driver != null)
                {
                    driver.Active      = "0";
                    driver.ServiceInfo = driver.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " удалил водителя";
                }

                ef.SaveChanges();
                ContentAddEdit.Hide();
                btn_refresh_Click(sender, e);
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
        /// Кнопка открыть окно редактирования
        private void btn_edit_Click(object sender, RoutedEventArgs e)
        {
            var bt      = e.OriginalSource as Button;
            var current = bt?.DataContext as Models.Drivers;

            ClearTextbox();

            btn_edit.Visibility   = Visibility.Visible;
            btn_add.Visibility    = Visibility.Collapsed;
            btn_delete.Visibility = Visibility.Visible;
            if (current == null)
            {
                return;
            }
            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == current.IdDriver);

                if (driver != null)
                {
                    text_namedriver.Text = driver.Family + " " + driver.Name + " " + driver.Patronymic;

                    tb_id.Text         = driver.IdDriver.ToString();
                    tb_Family.Text     = driver.Family;
                    tb_name.Text       = driver.Name;
                    tb_patronomyc.Text = driver.Patronymic;
                    tb_phone.Text      = driver.Phone;

                    tb_attorney.Text = driver.Attorney;
                    tb_auto.Text     = driver.Auto;
                    tb_autonum.Text  = driver.AutoNumber;
                    tb_passport.Text = driver.Passport;
                    tb_info.Text     = driver.Info;
                }
                ContentAddEdit.ShowAsync();
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
        /// Кнопка добавить водителя
        private void btn_add_driver_Click(object sender, RoutedEventArgs e)
        {
            ContentAddEdit.ShowAsync();
            ClearTextbox();
            text_namedriver.Text = "Добавить нового водителя";

            try
            {
                using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
                {
                    btn_add.Visibility    = Visibility.Visible;
                    btn_delete.Visibility = Visibility.Collapsed;
                }
            }
            catch (Exception ex)
            {
                ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
                ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
            }
        }
 /// Кнлпка удалить
 private void btn_delete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
         {
             var driver = ef.Drivers.FirstOrDefault(x => x.IdDriver == Convert.ToInt64(tb_id.Text));
             driver.Active      = "0";
             driver.ServiceInfo = driver.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " удалил водителя";
             ef.SaveChanges();
             ContentAddEdit.Hide();
             //btn_refresh_Click(sender, e);
         }
     }
     catch (Exception ex)
     {
         ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
         ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
     }
 }
        /// Кнопка добавить водителя
        private void btn_add_driver_Click(object sender, RoutedEventArgs e)
        {
            ContentAddEdit.ShowAsync();
            ClearTextbox();
            text_namedriver.Text = "Добавить нового водителя";

            try
            {
                using RegistrantCoreContext ef = new RegistrantCoreContext();
                btn_add.Visibility             = Visibility.Visible;
                btn_delete.Visibility          = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                if (mainWindow != null)
                {
                    mainWindow.ContentErrorText.ShowAsync();
                    mainWindow.text_debuger.Text = ex.ToString();
                }
            }
        }
 /// Кнопка закрытия диалогового окна с редактированием
 private void btn_close_Click(object sender, RoutedEventArgs e)
 {
     ContentAddEdit.Hide();
     btn_edit.Visibility = Visibility.Collapsed;
     btn_add.Visibility  = Visibility.Collapsed;
 }