private void MainDataGrid_OnRowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { try { switch (TabControl.SelectedIndex) { case 0: var dev = e.Row.Item as DEVELOPER; if (dev.DVLP_ID == 0) { _devRepo.Add(dev); } break; case 1: var game = e.Row.Item as GAME; if (game.ID_GAMES == 0) { _gameRepo.Add(game); } break; case 2: var man = e.Row.Item as MANAGER; if (man.MANAGER_ID == 0) { _manRepo.Add(man); } break; case 3: var art = e.Row.Item as ARTIST; if (art.ARTST_ID == 0) { _artRepo.Add(art); } break; } Update(); } catch { } }