private void btnExcluir_Click(object sender, RoutedEventArgs e) { if (lstProdutos.SelectedItem == null) { MessageBox.Show("Selecione um item"); return; } var itemDaVenda = (ItemDaVenda)lstProdutos.SelectedItem; repositorioItemDaVenda.Excluir(itemDaVenda); lstProdutos.DataContext = repositorioItemDaVenda.Liste(Codigo); }
private void btnExcluir_Click(object sender, RoutedEventArgs e) { if (Venda.StatusDaVenda != eStatusDaVenda.NOVA) { MessageBox.Show("Essa venda já foi efetivada!"); return; } if (lstVendas.SelectedItem == null) { MessageBox.Show("Selecione um item na lista"); return; } else { if (MessageBox.Show("Deseja remover um item da lista?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var itemDaVenda = (ItemDaVenda)lstVendas.SelectedItem; repositorioItemDaVenda.Excluir(itemDaVenda); try { lstVendas.DataContext = repositorioItemDaVenda.Liste(Codigo); } catch (Exception ex) { MessageBox.Show("Item removido com sucesso"); lstVendas.DataContext = repositorioItemDaVenda.Liste(Codigo); } //MessageBox.Show("Item removido com sucesso"); //lstVendas.DataContext = repositorioItemDaVenda.Liste(Codigo); } else { } } }