private void btnNext_Click(object sender, EventArgs e) { if (CurrentPage == 1) { switch (page1.Mode) { case Pages.ImportMode.UseExistingDs: if (page1.CurrentDataSource != null) { if (!page2.Init(TypedDataSource.GetFromTabularDs(page1.CurrentDataSource))) { return; } CurrentPage = 2; return; } break; case Pages.ImportMode.UseNewDs: var connectionDialog = ShowConnectionDialog(); if (connectionDialog == null) { return; } var source = TypedDataSource.GetFromConnectionUi(connectionDialog); var tabularDs = Model.AddDataSource(source.SuggestSourceName()); ConnectionUIHelper.ApplyToTabularDs(connectionDialog, tabularDs); source = TypedDataSource.GetFromTabularDs(tabularDs); page2.Init(source); CurrentPage = 2; return; case Pages.ImportMode.UseTempDs: connectionDialog = ShowConnectionDialog(); if (connectionDialog == null) { return; } source = TypedDataSource.GetFromConnectionUi(connectionDialog); source.TabularDsName = "(Temporary connection)"; page2.Init(source); CurrentPage = 2; return; case Pages.ImportMode.UseClipboard: page3.Visible = true; page3.BringToFront(); CurrentPage = 3; break; } } }
public void New() { var dcd = new DataConnectionDialog(); DataSource.AddStandardDataSources(dcd); dcd.SelectedDataSource = DataSource.SqlDataSource; dcd.SelectedDataProvider = DataProvider.SqlDataProvider; var res = DataConnectionDialog.Show(dcd); if (res == DialogResult.OK) { var ds = TypedDataSource.GetFromConnectionUi(dcd); } }