private void ButtonEditar_Click(object sender, RoutedEventArgs e) { if (DataGridProduto.SelectedItems.Count == 1) { if (p == null) { using (var ctx = new ERPDBModelContainer()) { p = new AdicionarProdutoWindow(ctx.ProdutoSet.Single(o => o.Id == ((ProdutoAdapter)DataGridProduto.SelectedItem).Id)); } p.Closed += (a, b) => p = null; p.buttonAdd.Click += Update; p.Show(); } else if (p.IsVisible) { p.Focus(); } else { p.Show(); } } else { MessageBox.Show("Você precisa selecionar apenas 1 Item"); } }
private void ButtonAdicionar_Click(object sender, System.Windows.RoutedEventArgs e) { if (p == null) { p = new AdicionarProdutoWindow(); p.Closed += (a, b) => p = null; p.buttonAdd.Click += Update; p.Show(); } else if (p.IsVisible) { p.Focus(); } else { p.Show(); } }