/// Непосредственное редактирование 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_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_close_Click(object sender, RoutedEventArgs e) { ContentAddEdit.Hide(); btn_edit.Visibility = Visibility.Collapsed; btn_add.Visibility = Visibility.Collapsed; }