Example #1
0
        public void Render(Epi.View view)
        {
            try
            {
                if (!view.IsRelatedView)
                {
                    EpiDashboard.DashboardHelper helper = new EpiDashboard.DashboardHelper(view, DBReadExecute.GetDataDriver(view.Project.FilePath));
                    dashboard = new EpiDashboard.DashboardControl(helper);

                    this.WindowState = FormWindowState.Maximized;

                    helper.SetDashboardControl(dashboard);
                    dashboard.RecordCountChanged += new EpiDashboard.RecordCountChangedHandler(dashboard_RecordCountChanged);
                    host.Child = dashboard;
                    dashboard.UpdateRecordCount();
                    dashboard.ReCacheDataSource();
                }
            }
            catch (Exception ex)
            {
                //temporarily catch all
            }
        }
Example #2
0
        public void Render(Epi.View view)
        {
            try
            {
                if (!view.IsRelatedView)
                {
                    EpiDashboard.DashboardHelper helper = new EpiDashboard.DashboardHelper(view, DBReadExecute.GetDataDriver(view.Project.FilePath));
                    dashboard = new EpiDashboard.DashboardControl(helper);

                    this.WindowState = FormWindowState.Maximized;

                    helper.SetDashboardControl(dashboard);
                    dashboard.RecordCountChanged += new EpiDashboard.RecordCountChangedHandler(dashboard_RecordCountChanged);
                    host.Child = dashboard;
                    dashboard.UpdateRecordCount();
                    dashboard.ReCacheDataSource();
                }
            }
            catch (Exception ex)
            {
                //temporarily catch all
            }
        }
        EpiDashboard.RelatedConnection dashboard_RelatedDataRequested()
        {
            if (this.dashboard.DashboardHelper == null)
            {
                Epi.Windows.MsgBox.ShowInformation(SharedStrings.DASHBOARD_CANNOT_RELATE_NO_DATA_SOURCE);
                return(null);
            }

            // May arrive here by opening a canvas file without going through normal request routine.
            this.dashboardHelper = this.dashboard.DashboardHelper;

            Epi.Windows.Dialogs.ReadRelatedDialog dlg = new Dialogs.ReadRelatedDialog(this.dashboard.DashboardHelper.TableColumnNames);

            if (dashboard.DashboardHelper.IsUsingEpiProject)
            {
                Dictionary <string, string> tableColumnNamesFiltered = new Dictionary <string, string>();

                foreach (KeyValuePair <string, string> kvp in this.dashboardHelper.TableColumnNames)
                {
                    if (kvp.Value.ToLowerInvariant() != "epi.fields.groupfield")
                    {
                        tableColumnNamesFiltered.Add(kvp.Key, kvp.Value);
                    }
                }

                dlg = new Dialogs.ReadRelatedDialog(this.dashboard.DashboardHelper.View.Project, tableColumnNamesFiltered);
            }
            EpiDashboard.RelatedConnection relatedConnection = null;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dlg.SelectedDataSource is Project && dlg.SelectedItemType == Dialogs.SelectedItemType.Form)
                {
                    Project   project  = (Project)dlg.SelectedDataSource;
                    View      view     = project.GetViewByName(dlg.SelectedDataMember);
                    IDbDriver dbDriver = DBReadExecute.GetDataDriver(project.FilePath);
                    relatedConnection = new EpiDashboard.RelatedConnection(view, dbDriver, dlg.ParentKeyField, dlg.ChildKeyField, dlg.UseUnmatched, false);

                    if (dashboardHelper.IsUsingEpiProject && dashboardHelper.View.Project.FilePath == project.FilePath)
                    {
                        relatedConnection.SameDataSource = true;
                    }
                }
                else if (dlg.SelectedDataSource is Project && dlg.SelectedItemType == Dialogs.SelectedItemType.Table)
                {
                    Project   project  = (Project)dlg.SelectedDataSource;
                    IDbDriver dbDriver = project.CollectedData.GetDbDriver();
                    relatedConnection = new EpiDashboard.RelatedConnection(dlg.SelectedDataMember, dbDriver, dlg.ParentKeyField, dlg.ChildKeyField, dlg.UseUnmatched, false);

                    if (dashboardHelper.IsUsingEpiProject && dashboardHelper.View.Project.FilePath == project.FilePath)
                    {
                        relatedConnection.SameDataSource = true;
                    }
                }
                else
                {
                    IDbDriver dbDriver = (IDbDriver)dlg.SelectedDataSource;
                    relatedConnection = new EpiDashboard.RelatedConnection(dlg.SelectedDataMember, dbDriver, dlg.ParentKeyField, dlg.ChildKeyField, dlg.UseUnmatched, false);
                }

                dashboard.ReCacheDataSource(false);

                return(relatedConnection);
            }
            return(null);
        }