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();
            }
        }
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            if (Selection != null)
            {
                var      selection  = ((CurrentSelection)Selection);
                var      editedItem = (IDbElement)selection.Grid.Items.GetItemAt(selection.Selected);
                DataGrid curDG      = null;
                DbType   curDT      = GetDbTypeFromName(selection.Grid.Name);
                dynamic  curWindow  = null;
                switch (curDT)
                {
                case DbType.Target:
                    curWindow = new TargetWindow((ProductTarget)editedItem);
                    curDG     = TargetDataGrid;
                    break;

                case DbType.Product:
                    curWindow = new ProductWindow(Manager.GetAllItemsListOf <ProductTarget>(), (Product)editedItem);
                    curDG     = ProductDataGrid;
                    break;

                case DbType.Task:
                    curWindow = new TaskWindow(Manager.GetAllItemsListOf <Product>(), (CompanyTask)editedItem);
                    curDG     = TaskDataGrid;
                    break;

                case DbType.Employee:
                    curWindow = new EmployeeWindow(Manager.GetAllItemsListOf <CompanyTask>(), (Employee)editedItem);
                    curDG     = EmployeeDataGrid;
                    break;
                }
                if (curWindow != null)
                {
                    if (curWindow.ShowDialog() == true && curWindow.Data != null && ((curWindow.Data.ID = editedItem.ID) == editedItem.ID))
                    {
                        Manager.EditItem((DbType)curDT, curWindow.Data);
                        curDG.ItemsSource = null; // I don't like this, but for some reason it doesn't work without it
                        ClearSelectionAll();
                        InitializeDataGrids();    // Reset DataGrids
                    }
                }
            }
        }