示例#1
0
        public void OpenRecord(Int64 Id)
        {
            try
            {
                DB.RPT_Report rptReport = BL.RPT.RPT_Report.Load(Id, DataContext);

                Templates.BaseReportTemplate report = new Templates.BaseReportTemplate();
                report.LoadLayoutFromXml(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(rptReport.Data)));
                report.Tag = String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", rptReport.Id, rptReport.Code, rptReport.Name, rptReport.Description, rptReport.Category, rptReport.SubCategory, rptReport.SecurityLevel);

                //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "Period", Type = typeof(DateTime), });

                //if (report.DataSource is DevExpress.DataAccess.Sql.SqlDataSource)
                //    ((DevExpress.DataAccess.Sql.SqlDataSource)(report.DataSource)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.SqlConnectionString.ConnectionString;
                //else if (report.DataSource is DevExpress.DataAccess.EntityFramework.EFDataSource)
                //    ((DevExpress.DataAccess.EntityFramework.EFDataSource)(report.DataSource)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.EntityViewConnectionString.ConnectionString;
                //else
                //    throw new Exception("Data Source type not implemented in reports");

                reportDesigner1.OpenReport(report);

                foreach (var componenet in report.Container.Components)
                {
                    if (!(componenet is DevExpress.DataAccess.Native.DataComponentBase))
                    {
                        continue;
                    }

                    if (componenet is DevExpress.DataAccess.Sql.SqlDataSource)
                    {
                        ((DevExpress.DataAccess.Sql.SqlDataSource)(componenet)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.SqlConnectionString.ConnectionString;
                    }
                    else if (componenet is DevExpress.DataAccess.EntityFramework.EFDataSource)
                    {
                        if (((DevExpress.DataAccess.EntityFramework.EFDataSource)(componenet)).Connection != null)
                        {
                            ((DevExpress.DataAccess.EntityFramework.EFDataSource)(componenet)).Connection.ConnectionString = BL.ApplicationDataContext.Instance.EntityViewConnectionString.ConnectionString;
                        }
                    }
                }
                while (xrDesignDockManager1.HiddenPanels.Count > 0)
                {
                    xrDesignDockManager1.HiddenPanels[0].Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                }

                //if (reportDesigner1.ActiveDesignPanel.Report.Scripts.OnParametersRequestBeforeShow == string.Empty)
                //{
                //    reportDesigner1.ActiveDesignPanel.Report.Scripts.OnParametersRequestBeforeShow = "XtraReport_ParametersRequestBeforeShow";
                //    reportDesigner1.ActiveDesignPanel.Report.ScriptsSource = xtraReport_ParametersRequestBeforeShow;
                //}
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }
示例#2
0
        private void bbiCopyReport_ItemClick(object sender, ItemClickEventArgs e)
        {
            MemoryStream ms = new MemoryStream();

            reportDesigner1.ActiveDesignPanel.Report.SaveLayout(ms, true);
            ms.Position = 0;
            Templates.BaseReportTemplate report = new Templates.BaseReportTemplate();
            report.LoadLayout(ms);
            report.Tag = null;
            reportDesigner1.OpenReport(report);
        }
示例#3
0
        internal bool NewRecord()
        {
            try
            {
                Templates.BaseReportTemplate report = new Templates.BaseReportTemplate();
                //XtraReport report = new XtraReport();
                //reportDesigner1.OpenReport(report);
                reportDesigner1.CreateNewReport();
                reportDesigner1.AddCommandHandler(new WizardCommandHandler(reportDesigner1.ActiveDesignPanel));
                reportDesigner1.ActiveDesignPanel.ExecCommand(ReportCommand.NewReportWizard);
                //reportDesigner1.CreateNewReportWizard();
                while (xrDesignDockManager1.HiddenPanels.Count > 0)
                {
                    xrDesignDockManager1.HiddenPanels[0].Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                }

                reportDesigner1.ActiveDesignPanel.Report.Scripts.OnParametersRequestBeforeShow = "XtraReport_ParametersRequestBeforeShow";
                reportDesigner1.ActiveDesignPanel.Report.ScriptsSource = xtraReport_ParametersRequestBeforeShow;

                if (reportDesigner1.ActiveDesignPanel.ReportState == ReportState.Changed)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

                //if (reportDesigner1.ActiveDesignPanel.ReportState != ReportState.Opened)
                //    return false;
                //else
                //    return true;
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
                return(false);
            }
        }