private void AddButton_Click(object sender, RoutedEventArgs e) { if (Selection != null) { dynamic curWindow = null; var selection = ((CurrentSelection)Selection); DbType curDT = GetDbTypeFromName(selection.Grid.Name); switch (curDT) { case DbType.Target: curWindow = new TargetWindow(); break; case DbType.Product: curWindow = new ProductWindow(Manager.GetAllItemsListOf <ProductTarget>()); break; case DbType.Task: curWindow = new TaskWindow(Manager.GetAllItemsListOf <Product>()); break; case DbType.Employee: curWindow = new EmployeeWindow(Manager.GetAllItemsListOf <CompanyTask>()); break; } if (curWindow != null) { if (curWindow.ShowDialog() == true && curWindow.Data != null) { Manager.AddItem(curDT, curWindow.Data); } } ClearSelectionAll(); } }