private void btnPreviewReport_Click(object sender, EventArgs e)
        {
            if (!_loading && cboAvailDataSources.SelectedIndex >= 0 && lstSelectedFields.Items.Count > 0)
            {
                ReportWizardDataSource dataSource = (ReportWizardDataSource)cboAvailDataSources.SelectedItem;

                List<SelectedField> selectedFields = new List<SelectedField>();
                foreach (SelectedField sf in lstSelectedFields.Items)
                {
                    selectedFields.Add(sf);
                }

                List<GroupField> groupFields = new List<GroupField>();
                foreach (GroupField gf in lstGroups.Items)
                {
                    groupFields.Add(gf);
                }

                List<string> filterStatements = new List<string>();
                foreach(string s in lstFilterStatement.Items)
                {
                    filterStatements.Add(s);
                }

                ReportViewer rv = null;
                try
                {
                    this.UseWaitCursor = true;

                    _reporterBO.TemplateDataSource = dataSource;
                    _reporterBO.TemplateSelectedFields = selectedFields;
                    _reporterBO.TemplateGroupFields = groupFields;
                    _reporterBO.TemplateFilterStatement = filterStatements;
                    _reporterBO.SetTemplateReportPath(selectedFields.Count);

                    rv = new ReportViewer(_reporterBO);
                    rv.TemplateBased = true;
                    rv.ShowDialog(this);

                }
                catch (Exception ex)
                {
                    _reporterBO.Log(ex.ToString());
                }
                finally
                {
                    if (rv != null)
                        rv.Dispose();

                    this.UseWaitCursor = false;
                }
            }
        }
示例#2
0
        private void ViewReport()
        {
            ReportViewer rv = null;
            try
            {
                this.UseWaitCursor = true;
                if (lstSystemReports.SelectedIndices.Count > 0)
                {
                    string reportPath = lstSystemReports.SelectedItems[0].SubItems[1].Text;
                    _reporterBO.SetSelectedReportByReportPath(reportPath);
                    rv = new ReportViewer(_reporterBO);
                    rv.ShowDialog(this);
                }
            }
            catch (Exception ex)
            {
                _reporterBO.Log(ex.ToString());
            }
            finally
            {
                if (rv != null)
                    rv.Dispose();

                this.UseWaitCursor = false;
            }
        }