public bool EditDataSource( Flex.C1FlexReport report, Hashtable dataSchema, Flex.DataSource dataSource, FlexDesignerHostServices services, bool newDataSource = false) { _report = report; _newDataSource = newDataSource; _cmbDataSourceName.DropDownStyle = ComboBoxStyle.DropDownList; foreach (Flex.DataSource ds in report.DataSources) { _cmbDataSourceName.Items.Add(ds.Name); } // System.Diagnostics.Debug.Assert(_report.DataSources.Contains(dataSource), "We can only handle datasources that are in the report's DataSources collection"); // _dspMain.DataSchema = dataSchema; SetDataSource(dataSource); // initialize picker control _dspMain.DesignerHostServices = services; // _dspMain.DataSource = dataSource; // set up form events // _dspMain.DoubleClick += new EventHandler(_btnOK_Click); // ready to go return(ShowDialog() == DialogResult.OK); }
// save results and dismiss dialog private void _btnOK_Click(object sender, System.EventArgs e) { if (!_dspMain.RecordSourceSelected) { // AppUtils.ShowWarning(Strings.DataSourceForm.SelectDataSource); MessageForm.Warn(Strings.DataSourceForm.SelectDataSource); return; } // apply changes _dataSource.DataProvider = _dspMain.DataProvider; _dataSource.ConnectionString = _dspMain.ConnectionString; _dataSource.RecordSource = _dspMain.RecordSource; _dataSource.RecordSourceType = _dspMain.RecordSourceType; _dataSource.Recordset = _dspMain.Recordset; // IList <DataSourcePicker.ReportParameterDesc> prms = _dspMain.GetRecordSourceParameters(); if (prms != null && prms.Count > 0) { Flex.C1FlexReport report = _dataSource.ParentReport; foreach (DataSourcePicker.ReportParameterDesc rpd in prms) { Flex.ReportParameter rp = (Flex.ReportParameter)report.Parameters.FindByName(rpd.Name); if (rp == null) { rp = new Flex.ReportParameter(); rp.Name = rpd.Name; rp.DataType = rpd.Type; report.Parameters.Add(rp); } } } // done DialogResult = DialogResult.OK; }