public void reset() { using (progIInoitesegEntities bd = new progIInoitesegEntities()) { ListaAlunos = new ObservableCollection <aluno>(bd.alunos.Include("notas")); AlunosView = CollectionViewSource.GetDefaultView(ListaAlunos); AlunoCorrente = (aluno)AlunosView.CurrentItem; AlunosView.CurrentChanged += AlunosView_CurrentChanged; } }
//Create Retrieve Update Delete public void updateAluno(aluno a) { int aqui = 0; using (progIInoitesegEntities bd = new progIInoitesegEntities()) { var este = bd.alunos.Where(x => x.num == a.num).First(); if (este != null) { aqui = este.num; este.nome = a.nome; este.curso = a.curso; este.fotopath = a.fotopath; bd.SaveChanges(); } reset(); var novo = ListaAlunos.Where(x => x.num == aqui).First(); AlunosView.MoveCurrentTo(novo); System.Windows.MessageBox.Show("Registo gravado."); } }