/// <summary> /// Otwiera formularz wyboru i pobiera z niego identyfikator bazodanowy wybranego przez użytkownika obiektu /// </summary> /// <returns>Identyfikator bazodanowy wybranego obiektu, null dla braku wyboru</returns> public int?Start() { TabContents tabContents = _entityChoiceForm.Controls[0] as TabContents; Dictionary <string, EventHandler> actions = GetActions(); tabContents.FillActionArea(actions); if (_entityChoiceForm.ShowDialog() == DialogResult.OK) { return((tabContents.DataGrid.CurrentRow.DataBoundItem as IDBModel).Id); } else { return(null); } }
/// <summary> /// Kliknięcię w przycisk otwierania nowej karty. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void OpenTabHandler <T>(object sender, EventArgs eventArgs) where T : class, IDBModel, new() { TabPage newTab = _mainForm.GetRecentlyOpenedTab(); var dataSource = _dataSourceManager.Get <T>(); if (dataSource != null) { TabContents tabContents = newTab.Controls[0] as TabContents; tabContents.DataGrid.DataSource = dataSource; tabContents.FillActionArea(GetActionsFor <T>()); } else { _mainForm.CloseTab(newTab); MessageBox.Show(_dataSourceManager.LastErrorMessage); } }