Exemplo n.º 1
0
 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");
     }
 }
Exemplo n.º 2
0
 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();
     }
 }