示例#1
0
        public virtual void AfterGenerateReport(GenerateReportParameter Paras)
        {
            if (Paras.GenerateReportResult != null)
            {
                switch (Paras.GenerateReportResult.ExecutionResult)
                {
                case eExecutionResult.CommitedSucessfuly:
                    //Alit.WinformControls.ToastNotification.Show(this, "Report generated successfully");
                    if (!String.IsNullOrWhiteSpace(Paras.GenerateReportResult.MessageAfterReportGenerated))
                    {
                        Alit.WinformControls.MessageBox.Show(this, Paras.GenerateReportResult.MessageAfterReportGenerated, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    break;

                case eExecutionResult.ErrorWhileExecuting:
                    Alit.WinformControls.MessageBox.Show(this,
                                                         (Paras.GenerateReportResult.Exception.Message.Length > 500 ? Paras.GenerateReportResult.Exception.Message.Substring(0, 500) : Paras.GenerateReportResult.Exception.Message),
                                                         MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case eExecutionResult.ValidationError:
                    Alit.WinformControls.MessageBox.Show(this, "Can not generate report, please check following validation issue.\r\n\r\n" + Paras.GenerateReportResult.ValidationError,
                                                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
            }
        }
示例#2
0
        public void ExecuteGenerateReport()
        {
            if (!ValidateBeforeSave())
            {
                if (FirstControl != null && FirstControl.CanFocus)
                {
                    FirstControl.Focus();
                }
                return;
            }

            GenerateReportParameter ReportParas = new GenerateReportParameter();
            XtraReport ReportSource             = null;

            GenerateReport(ReportParas, ref ReportSource);

            if (UseGeneralizeHeader && ReportSource != null)
            {
                float FullPageWidth = ReportSource.PageWidth - (ReportSource.Margins.Left + ReportSource.Margins.Right);//(ReportSource.PaperKind == PaperKind.A5 ? (ReportSource.Landscape ? 0f : 533f) : (ReportSource.Landscape ? 0f : 777f));
                ///-- Designing generalize header and footer
                ///

                ReportHeader = ReportSource.Bands.OfType <DevExpress.XtraReports.UI.ReportHeaderBand>().FirstOrDefault();
                if (ReportHeader == null)
                {
                    ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
                    ReportSource.Bands.Add(ReportHeader);
                }
                PageHeader = ReportSource.Bands.OfType <DevExpress.XtraReports.UI.PageHeaderBand>().FirstOrDefault();
                if (PageHeader == null)
                {
                    PageHeader = new DevExpress.XtraReports.UI.PageHeaderBand();
                    ReportSource.Bands.Add(PageHeader);
                }

                var ReportFooterBand = ReportSource.Bands.OfType <DevExpress.XtraReports.UI.ReportFooterBand>().FirstOrDefault();
                if (ReportFooterBand == null)
                {
                    ReportFooterBand = new ReportFooterBand();//new DevExpress.XtraReports.UI.PageFooterBand();
                    ReportSource.Bands.Add(ReportFooterBand);
                }
                ReportFooterBand.PrintAtBottom = true;

                var xrlpfTopLine        = new DevExpress.XtraReports.UI.XRLine();
                var xrpipfPrintDateTime = new DevExpress.XtraReports.UI.XRPageInfo();
                var xrpipfPageNo        = new DevExpress.XtraReports.UI.XRPageInfo();

                var xrlrhCompanyName           = new DevExpress.XtraReports.UI.XRLabel();
                var xrlrhCompanyAddress        = new DevExpress.XtraReports.UI.XRLabel();
                var xrlrhCompanyContactDetails = new DevExpress.XtraReports.UI.XRLabel();

                xrlrhReportTitle1 = new DevExpress.XtraReports.UI.XRLabel();
                xrlrhReportTitle2 = new DevExpress.XtraReports.UI.XRLabel();

                xrlphReportTitle1 = new DevExpress.XtraReports.UI.XRLabel();
                xrlphReportTitle2 = new DevExpress.XtraReports.UI.XRLabel();

                ((System.ComponentModel.ISupportInitialize)(ReportSource)).BeginInit();


                //
                // xrlpfTopLine
                //
                xrlpfTopLine.LocationFloat = new DevExpress.Utils.PointFloat(0F, 0F);
                xrlpfTopLine.Name          = "xrlpfTopLine";
                xrlpfTopLine.SizeF         = new System.Drawing.SizeF(FullPageWidth, 5F);

                //
                // pageFooterBand1
                //

                ReportFooterBand.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
                    xrpipfPrintDateTime,
                    xrpipfPageNo,
                    xrlpfTopLine
                });
                ReportFooterBand.HeightF = 29F;
                ReportFooterBand.Name    = "pageFooterBand1";
                //
                // xrpipfPrintDateTime
                //
                //xrpipfPrintDateTime.Borders = DevExpress.XtraPrinting.BorderSide.All;
                xrpipfPrintDateTime.Font          = new System.Drawing.Font("Arial", 10F);
                xrpipfPrintDateTime.LocationFloat = new DevExpress.Utils.PointFloat(0F, 7F);
                xrpipfPrintDateTime.Name          = "xrpipfPrintDateTime";
                xrpipfPrintDateTime.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
                xrpipfPrintDateTime.PageInfo      = DevExpress.XtraPrinting.PageInfo.DateTime;
                xrpipfPrintDateTime.SizeF         = new System.Drawing.SizeF(200F, 20F);
                xrpipfPrintDateTime.StyleName     = "PageInfo";
                //
                // xrpipfPageNo
                //
                //xrpipfPageNo.Borders = DevExpress.XtraPrinting.BorderSide.All;
                xrpipfPageNo.Font          = new System.Drawing.Font("Arial", 10F);
                xrpipfPageNo.Format        = "Page {0} of {1}";
                xrpipfPageNo.LocationFloat = new DevExpress.Utils.PointFloat(FullPageWidth - 150, 7F);
                xrpipfPageNo.Name          = "xrpipfPageNo";
                xrpipfPageNo.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
                xrpipfPageNo.SizeF         = new System.Drawing.SizeF(150F, 20F);
                xrpipfPageNo.StyleName     = "PageInfo";
                xrpipfPageNo.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;

                //
                //Page Header
                //
                PageHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { xrlphReportTitle1, xrlphReportTitle2 });
                //
                // PageHeader
                //
                PageHeader.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;
                PageHeader.HeightF = 55F;
                PageHeader.Name    = "PageHeader";
                PageHeader.PrintOn = DevExpress.XtraReports.UI.PrintOnPages.NotWithReportHeader;
                PageHeader.StylePriority.UseBorders = false;

                //
                // xrlphReportTitle
                //
                xrlphReportTitle1.Font                           = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold);
                xrlphReportTitle1.CanShrink                      = true;
                xrlphReportTitle1.ProcessNullValues              = ValueSuppressType.SuppressAndShrink;
                xrlphReportTitle1.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 0F);
                xrlphReportTitle1.Name                           = "xrlphReportTitle1";
                xrlphReportTitle1.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 10, 10, 100F);
                xrlphReportTitle1.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 30F);
                xrlphReportTitle1.StylePriority.UseFont          = false;
                xrlphReportTitle1.StylePriority.UseTextAlignment = false;
                xrlphReportTitle1.Text                           = ReportTitle1;
                xrlphReportTitle1.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.BottomCenter;


                //
                // xrlphReportTitle
                //
                xrlphReportTitle2.Font                           = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Bold);
                xrlphReportTitle2.CanShrink                      = true;
                xrlphReportTitle2.ProcessNullValues              = ValueSuppressType.SuppressAndShrink;
                xrlphReportTitle2.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 30F);
                xrlphReportTitle2.Name                           = "xrlphReportTitle2";
                xrlphReportTitle2.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F);
                xrlphReportTitle2.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 25F);
                xrlphReportTitle2.StylePriority.UseFont          = false;
                xrlphReportTitle2.StylePriority.UseTextAlignment = false;
                xrlphReportTitle2.Text                           = ReportTitle2;
                xrlphReportTitle2.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.TopCenter;

                //
                // ReportHeader
                //
                ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
                    xrlrhCompanyName,
                    xrlrhCompanyAddress,
                    xrlrhCompanyContactDetails,
                    xrlrhReportTitle1, xrlrhReportTitle2
                });

                ReportHeader.HeightF = 120f;
                ReportHeader.Name    = "ReportHeader";
                //
                // xrlrhCompanyName
                //
                xrlrhCompanyName.CanGrow                        = false;
                xrlrhCompanyName.Font                           = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold);
                xrlrhCompanyName.ForeColor                      = System.Drawing.Color.Black;
                xrlrhCompanyName.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 0F);
                xrlrhCompanyName.Name                           = "xrlrhCompanyName";
                xrlrhCompanyName.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
                xrlrhCompanyName.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 25F);
                xrlrhCompanyName.StyleName                      = "Title";
                xrlrhCompanyName.StylePriority.UseFont          = false;
                xrlrhCompanyName.StylePriority.UseForeColor     = false;
                xrlrhCompanyName.StylePriority.UseTextAlignment = false;
                xrlrhCompanyName.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.BottomCenter;
                xrlrhCompanyName.Text                           = CommonProperties.LoginInfo.LoggedInCompanyReportModel.CompanyName;
                //
                // xrlrhCompanyAddress
                //
                xrlrhCompanyAddress.Font                           = new System.Drawing.Font("Arial", 10F);
                xrlrhCompanyAddress.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 25F);
                xrlrhCompanyAddress.Name                           = "xrlrhCompanyAddress";
                xrlrhCompanyAddress.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
                xrlrhCompanyAddress.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 20F);
                xrlrhCompanyAddress.StylePriority.UseFont          = false;
                xrlrhCompanyAddress.StylePriority.UseTextAlignment = false;
                xrlrhCompanyAddress.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                xrlrhCompanyAddress.Text                           = CommonProperties.LoginInfo.LoggedInCompanyReportModel.AddressWithCity;
                //
                // xrlrhCompanyContactDetails
                //
                //xrlrhCompanyContactDetails.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;
                xrlrhCompanyContactDetails.Font                           = new System.Drawing.Font("Arial", 10F);
                xrlrhCompanyContactDetails.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 45F);
                xrlrhCompanyContactDetails.Name                           = "xrlrhCompanyContactDetails";
                xrlrhCompanyContactDetails.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
                xrlrhCompanyContactDetails.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 20F);
                xrlrhCompanyContactDetails.StylePriority.UseBorders       = false;
                xrlrhCompanyContactDetails.StylePriority.UseFont          = false;
                xrlrhCompanyContactDetails.StylePriority.UseTextAlignment = false;
                xrlrhCompanyContactDetails.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                xrlrhCompanyContactDetails.Text                           = CommonProperties.LoginInfo.LoggedInCompanyReportModel.ContactDetails;
                //
                // xrlrhReportTitle
                //
                //xrlrhReportTitle1.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;
                xrlrhReportTitle1.Font                           = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold);
                xrlrhReportTitle1.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 65F);
                xrlrhReportTitle1.Name                           = "xrlrhReportTitle1";
                xrlrhReportTitle1.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F);
                xrlrhReportTitle1.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 30F);
                xrlrhReportTitle1.StylePriority.UseBorders       = false;
                xrlrhReportTitle1.StylePriority.UseFont          = false;
                xrlrhReportTitle1.StylePriority.UseTextAlignment = false;
                xrlrhReportTitle1.Text                           = ReportTitle1;
                xrlrhReportTitle1.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.BottomCenter;

                //
                // xrlrhReportTitle
                //
                xrlrhReportTitle2.Borders                        = DevExpress.XtraPrinting.BorderSide.Bottom;
                xrlrhReportTitle2.Font                           = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Bold);
                xrlrhReportTitle2.LocationFloat                  = new DevExpress.Utils.PointFloat(0F, 95F);
                xrlrhReportTitle2.Name                           = "xrlrhReportTitle2";
                xrlrhReportTitle2.Padding                        = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F);
                xrlrhReportTitle2.SizeF                          = new System.Drawing.SizeF(FullPageWidth, 25F);
                xrlrhReportTitle2.StylePriority.UseBorders       = false;
                xrlrhReportTitle2.StylePriority.UseFont          = false;
                xrlrhReportTitle2.StylePriority.UseTextAlignment = false;
                xrlrhReportTitle2.Text                           = ReportTitle2;
                xrlrhReportTitle2.TextAlignment                  = DevExpress.XtraPrinting.TextAlignment.TopCenter;

                ((System.ComponentModel.ISupportInitialize)(ReportSource)).EndInit();
            }
            ///--
            DocViwer.DocumentSource = ReportSource;
            if (ReportSource != null)
            {
                ReportSource.CreateDocument(true);
            }
            ///-
            AfterGenerateReport(ReportParas);
            //--
            //if (ReportParas.GenerateReportResult != null && ReportParas.GenerateReportResult.ExecutionResult == eExecutionResult.CommitedSucessfuly)
            //{
            //    ResetFormView();
            //}
            //FirstControl.Focus();
            DocViwer.Focus();
            //--
            Application.DoEvents();
        }
示例#3
0
 public virtual void GenerateReport(GenerateReportParameter Paras, ref XtraReport ReportSource)
 {
 }