private void EditWindow_Closing(object sender, DataGrid originalTable, int selectedIndex, int originalType) { DocumentEditWindow editWindow = (DocumentEditWindow)sender; DocTable item = sources[originalTable][selectedIndex]; int newType = (int)editWindow.DocTypeCombo.SelectedValue; if (newType != originalType) { sources[originalTable].RemoveAt(selectedIndex); sources[originalTable].AddIndexes(); originalTable.Items.Refresh(); if (typeToTable.ContainsKey(newType)) { sources[typeToTable[newType]].Add(item); sources[typeToTable[newType]].AddIndexes(); typeToTable[newType].Items.Refresh(); } else { //if there's no table generated then there is no need to add somewhere return; } } item.name = editWindow.DocumentName.Text; item.date = DatabaseHandler.GetDocumentDate(item.id); //TODO UPDATE POINTS }