public void incluirLista(List <ItemBacklog> lista) { if (lista.Count > 0) { List <ItemBacklog> listaBanco = itemBacklogDAO.recuperar(); List <ItemBacklog> listaItemBacklogInclusao = new List <ItemBacklog>(); List <ItemBacklog> listaItemBacklogAtualizacao = new List <ItemBacklog>(); foreach (ItemBacklog ItemBacklog in lista) { var ItemBacklogsExistente = listaBanco.Where(t => t.Id.Equals(ItemBacklog.Id)); if (ItemBacklogsExistente.Count() == 0) { listaItemBacklogInclusao.Add(ItemBacklog); } else { ItemBacklog.Codigo = ((ItemBacklog)ItemBacklogsExistente.First()).Codigo; listaItemBacklogAtualizacao.Add(ItemBacklog); } } itemBacklogDAO.incluir(listaItemBacklogInclusao); itemBacklogDAO.atualizar(listaItemBacklogAtualizacao); } }
private void tblItemBacklog_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { // ... Get the TextBox that was edited. var element = e.EditingElement as System.Windows.Controls.TextBox; var text = element.Text; ItemBacklog item = (ItemBacklog)e.Row.Item; var coluna = e.Column.DisplayIndex; // ... See if the text edit should be canceled. // We cancel if the user typed a question mark. if (text.Length == 0) { e.Cancel = true; } else { ItemBacklogDAO iDAO = new ItemBacklogDAO(); if (coluna < 7) { Alerta alerta = new Alerta("Somente as colunas Valor Negocio, Tamanho, Complexidade e PF podem ser alteradas"); alerta.Show(); e.Cancel = true; } else { if (coluna == 7) { item.ValorNegocio = Convert.ToInt32(text); } else if (coluna == 8) { item.Tamanho = Convert.ToInt32(text); } else if (coluna == 9) { item.Complexidade = Convert.ToInt32(text); } else if (coluna == 10) { item.Pf = Convert.ToDecimal(text); } iDAO.atualizar(item.encapsularLista()); } } }