private void AddButton_Click(object sender, RoutedEventArgs e) { var editWindow = new EditWindow(false); editWindow.Show(); editWindow.Closed += EditWindow_Closed; }
private void StudentsDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGrid dataGrid = (DataGrid)sender; Student student = (Student)dataGrid.SelectedItem; var editWindow = new EditWindow(true); editWindow.InsertStudent(student); editWindow.Show(); editWindow.Closed += EditWindow_Closed; }
private void EditWindow_Closed(object sender, EventArgs e) { EditWindow editWindow = (EditWindow)sender; if (0 != editWindow.CurrentStudent.IdStudent && false == editWindow.editMode) { if (!ListaStudentow.Contains(editWindow.CurrentStudent)) { ListaStudentow.Add(editWindow.CurrentStudent); } } if (0 != editWindow.CurrentStudent.IdStudent && true == editWindow.editMode) { ListaStudentow.Where(w => w.IdStudent == editWindow.CurrentStudent.IdStudent).ToList().ForEach(s => { s.FirstName = editWindow.CurrentStudent.FirstName; s.LastName = editWindow.CurrentStudent.LastName; s.IndexNumber = editWindow.CurrentStudent.IndexNumber; s.Address = editWindow.CurrentStudent.Address; }); } }