private void Button_Click_1(object sender, RoutedEventArgs e) { string Usuario = Thread.CurrentPrincipal.Identity.Name; string NoDocument = NoDocumento.Text; Thread thread = new Thread(() => { var win = new EditPersona(NoDocument, Usuario) { DataContext = new ViewModelEditPersona(NoDocument) }; win.Show(); win.Closed += (sender1, e1) => win.Dispatcher.InvokeShutdown(); System.Windows.Threading.Dispatcher.Run(); CloseWindow(); }); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); }
private void Edit_Click(object sender, RoutedEventArgs e) { RedEmpleoOffLineEntities db = new RedEmpleoOffLineEntities(); var button = (FrameworkElement)sender; var row = (DataGridRow)button.Tag; var content = ((System.Data.DataRowView)(row.Item)).Row.ItemArray[4]; string tipodoc = content.ToString().Substring(0, 2); string NoIdentificacion = content.ToString().Replace("CC", "").Replace("TI", "").Replace("CE", "").Replace("PA", ""); var AllowEdit = (from p in db.Personas where p.NoDocumento.Equals(NoIdentificacion) && p.TipoDocumento.Equals(tipodoc) select p.AllowEdit).FirstOrDefault(); if (!AllowEdit == false) { var UsuarioExistente = (from p in db.Personas where p.NoDocumento.Equals(NoIdentificacion) select p.UsuarioValido).FirstOrDefault(); string Usuario = LebelUsuario.Content.ToString(); Thread thread = new Thread(() => { var win = new EditPersona(content.ToString(), Usuario) { DataContext = new ViewModelEditPersona(NoIdentificacion) }; win.Show(); win.Closed += (sender1, e1) => win.Dispatcher.InvokeShutdown(); System.Windows.Threading.Dispatcher.Run(); RefrescarDatagrid(); }); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); this.Visibility = Visibility.Collapsed; } else { MessageBox.Show("Oferente Sincronizado"); } }