private void BtnAdicionar_Click(object sender, RoutedEventArgs e) { int[] handles = grdItens.GetSelectedRowHandles(); if (handles.Length > 0) { foreach (var rowHandle in handles) { dto = grdItens.GetRow(rowHandle) as EntradaManualEstoqueDTO; listaEntrada.Add(dto); } } DialogResult = true; }
private void AdicionarEstoque_Click(object sender, RoutedEventArgs e) { bool iNotify = false; int[] handles = grdItens.GetSelectedRowHandles(); if (handles.Length > 0) { listaInserir = new ObservableCollection <EntradaManualEstoqueDTO>(); foreach (int rowHandle in handles) { dto = grdItens.GetRow(rowHandle) as EntradaManualEstoqueDTO; if (dto.Quantidade != 0 && dto.Custo != 0) { listaInserir.Add(dto); } else { iNotify = true; } } if (iNotify) { CustomOKMessageBox.Show("Existem itens que possuem a quantidade ou o preço zerado.", "Atenção!", Window.GetWindow(this)); } else { System.Windows.Forms.DialogResult result = CustomOKCancelMessageBox.Show("Deseja mesmo dar entrada nos itens selecionados?", "Atenção!", Window.GetWindow(this)); if (result == System.Windows.Forms.DialogResult.OK) { bll.InserirEstoque(listaInserir); List <int> selectedRowHandles = new List <int>(grdItens.GetSelectedRowHandles()); IOrderedEnumerable <int> descendingOrder = selectedRowHandles.OrderByDescending(i => i); grdItens.BeginDataUpdate(); foreach (int i in descendingOrder) { grdView.DeleteRow(i); } grdItens.EndDataUpdate(); CustomOKMessageBox.Show("Itens adicionados com sucesso ao estoque.", "Sucesso!", Window.GetWindow(this)); } } } }