我的全代碼控制xrReport

来源:互联网 发布:rose only和beast 知乎 编辑:程序博客网 时间:2024/05/22 23:48

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using Project.Shared.Reporting;
using Project.Shared.Reporting.Win;
using Project.BLL;
using System.Drawing.Printing;
using System.Data;
using Project.BLL.ReportEntities;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting;
using Csla;

namespace Project.Win.Reports
{
    public partial class AnalysisReport : DevExpress.XtraReports.UI.XtraReport, IReport, IReportLayout
    {
        #region Designer

        /// <summary>
        /// Required designer variable.
        /// </summary>

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        #region Designer code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.bandReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
            this.tableReportHeader = new DevExpress.XtraReports.UI.XRTable();
            this.rowReportHeader = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandPageHeader = new DevExpress.XtraReports.UI.PageHeaderBand();
            this.tablePageHeader = new DevExpress.XtraReports.UI.XRTable();
            this.rowPageHeader = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandPrimaryHeader = new DevExpress.XtraReports.UI.GroupHeaderBand();
            this.tablePrimaryHeader = new DevExpress.XtraReports.UI.XRTable();
            this.rowPrimaryHeader = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandSecondaryHeader = new DevExpress.XtraReports.UI.GroupHeaderBand();
            this.tableSecondaryHeader = new DevExpress.XtraReports.UI.XRTable();
            this.rowSecondaryHeader = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandDetail = new DevExpress.XtraReports.UI.DetailBand();
            this.tableDetail = new DevExpress.XtraReports.UI.XRTable();
            this.rowDetail = new XRTableRow();

            this.bandSecondaryFooter = new DevExpress.XtraReports.UI.GroupFooterBand();
            this.tableSecondaryFooter = new DevExpress.XtraReports.UI.XRTable();
            this.rowSecondaryFooter = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandPrimaryFooter = new DevExpress.XtraReports.UI.GroupFooterBand();
            this.tablePrimaryFooter = new DevExpress.XtraReports.UI.XRTable();
            this.rowPrimaryFooter = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandReportFooter = new DevExpress.XtraReports.UI.ReportFooterBand();
            this.tableReportFooter = new DevExpress.XtraReports.UI.XRTable();
            this.rowReportFooter = new DevExpress.XtraReports.UI.XRTableRow();

            this.bandPageFooter = new DevExpress.XtraReports.UI.PageFooterBand();
            this.tablePageFooter = new DevExpress.XtraReports.UI.XRTable();
            this.rowPageFooter = new DevExpress.XtraReports.UI.XRTableRow();

            ((System.ComponentModel.ISupportInitialize)(this.tableDetail)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePageHeader)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePrimaryHeader)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePrimaryFooter)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableReportFooter)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableReportHeader)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableSecondaryHeader)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableSecondaryFooter)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePageFooter)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();

            InitPropertyValue(); //Init Properties values in this method

            #region Report Header

            //
            // bandReportHeader
            //
            this.bandReportHeader.Name = "bandReportHeader";
            this.bandReportHeader.Padding = _bandPaddingInfo;
            this.bandReportHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tableReportHeader
            //
            this.tableReportHeader.Location = table_ReportHeader_Location;
            this.tableReportHeader.Name = "tableReportHeader";
            this.tableReportHeader.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowReportHeader });
            this.tableReportHeader.Size = new Size(table_ReportHeader_Width, table_ReportHeader_Height);

            #endregion

            #region Page Header
            //
            // bandPageHeader
            //
            this.bandPageHeader.Name = "bandPageHeader";
            this.bandPageHeader.Padding = _bandPaddingInfo;
            this.bandPageHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tablePageHeader
            //
            this.tablePageHeader.Location = table_PageHeader_Location;
            this.tablePageHeader.Name = "tablePageHeader";
            this.tablePageHeader.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowPageHeader });
            this.tablePageHeader.Size = new Size(table_PageHeader_Width, table_PageHeader_Height);

            #endregion

            #region Group Header - Primary
            //
            // bandPrimaryHeader
            //
            this.bandPrimaryHeader.Level = 1;
            this.bandPrimaryHeader.Name = "bandPrimaryHeader";
            this.bandPrimaryHeader.Padding = _bandPaddingInfo;
            this.bandPrimaryHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tablePrimaryHeader
            //
            this.tablePrimaryHeader.Location = table_PrimaryHeader_Location;
            this.tablePrimaryHeader.Name = "tablePrimaryHeader";
            this.tablePrimaryHeader.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowPrimaryHeader });
            this.tablePrimaryHeader.Size = new Size(table_PrimaryHeader_Width, table_PrimaryHeader_Height);

            #endregion

            #region Group Header - Secondary

            //
            // bandSecondaryHeader
            //
            this.bandSecondaryHeader.Name = "bandSecondaryHeader";
            this.bandSecondaryHeader.Padding = _bandPaddingInfo;
            this.bandSecondaryHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tableSecondaryHeader
            //
            this.tableSecondaryHeader.Location = table_SecondaryHeader_Location;
            this.tableSecondaryHeader.Name = "tableSecondaryHeader";
            this.tableSecondaryHeader.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowSecondaryHeader });
            this.tableSecondaryHeader.Size = new Size(table_SecondaryHeader_Width, table_SecondaryHeader_Height);

            #endregion

            #region Detail

            //
            // bandDetail
            //
            this.bandDetail.Name = "bandDetail";
            this.bandDetail.Padding = _bandPaddingInfo;
            this.bandDetail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tableDetail
            //
            this.tableDetail.Location = table_Detail_Location;
            this.tableDetail.Name = "tableDetail";
            this.tableDetail.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowDetail });
            this.tableDetail.Size = new Size(table_Detail_Width, table_Detail_Height);

            #endregion

            #region Group Footer - Secondary

            //
            // bandSecondaryFooter
            //
            this.bandSecondaryFooter.Name = "bandSecondaryFooter";
            this.bandSecondaryFooter.Padding = _bandPaddingInfo;
            this.bandSecondaryFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tableSecondaryFooter
            //
            this.tableSecondaryFooter.Location = table_SecondaryFooter_Location;
            this.tableSecondaryFooter.Name = "tableSecondaryFooter";
            this.tableSecondaryFooter.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowSecondaryFooter });
            this.tableSecondaryFooter.Size = new Size(table_SecondaryFooter_Width, table_SecondaryFooter_Height);

            #endregion

            #region Group Footer - Primary

            //
            // bandPrimaryFooter
            //
            this.bandPrimaryFooter.Level = 1;
            this.bandPrimaryFooter.Name = "bandPrimaryFooter";
            this.bandPrimaryFooter.Padding = _bandPaddingInfo;
            this.bandPrimaryFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tablePrimaryFooter
            //
            this.tablePrimaryFooter.Location = table_PrimaryFooter_Location;
            this.tablePrimaryFooter.Name = "tablePrimaryFooter";
            this.tablePrimaryFooter.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowPrimaryFooter });
            this.tablePrimaryFooter.Size = new Size(table_PrimaryFooter_Width, table_PrimaryFooter_Height);

            #endregion

            #region Report Footer

            //
            // bandReportFooter
            //
            this.bandReportFooter.Name = "bandReportFooter";
            this.bandReportFooter.Padding = _bandPaddingInfo;
            this.bandReportFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tableReportFooter
            //
            this.tableReportFooter.Location = table_ReportFooter_Location;
            this.tableReportFooter.Name = "tableReportFooter";
            this.tableReportFooter.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowReportFooter });
            this.tableReportFooter.Size = new Size(table_ReportFooter_Width, table_ReportFooter_Height);

            #endregion

            #region Page Footer

            //
            // bandPageFooter
            //
            this.bandPageFooter.Name = "bandPageFooter";
            this.bandPageFooter.Padding = _bandPaddingInfo;
            this.bandPageFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            //
            // tablePageFooter
            //
            this.tablePageFooter.Location = table_PageFooter_Location;
            this.tablePageFooter.Name = "tablePageFooter";
            this.tablePageFooter.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.rowPageFooter });
            this.tablePageFooter.Size = new Size(table_PageFooter_Width, table_PageFooter_Height);

            #endregion

            InitBands(); //Init all bands in this method

            #region Reset Width

            if (useColumnWidth)
            {
                if (_maxWidth < _minWidth)
                    _maxWidth = _minWidth;

                page_Width = _maxWidth + page_Margins.Left + page_Margins.Right + page_Padding_Left + page_Padding_Right;
                table_ReportHeader_Width = _maxWidth;
                table_PageHeader_Width = _maxWidth;
                table_PrimaryHeader_Width = _maxWidth;
                table_SecondaryHeader_Width = _maxWidth;
                table_Detail_Width = _maxWidth;
                table_SecondaryFooter_Width = _maxWidth;
                table_PrimaryFooter_Width = _maxWidth;
                table_ReportFooter_Width = _maxWidth;
                table_PageFooter_Width = _maxWidth;
            }

            this.PageWidth = page_Width;
            this.tableReportHeader.Width = table_ReportHeader_Width;            // Report Header
            this.rowReportHeader.Width = this.tableReportHeader.Width;
            this.tablePageHeader.Width = table_PageHeader_Width;                // Page Header
            this.rowPageHeader.Width = this.tablePageHeader.Width;
            this.tablePrimaryHeader.Width = table_PrimaryHeader_Width;     // Primary Header
            this.rowPrimaryHeader.Width = this.tablePrimaryHeader.Width;
            this.tableSecondaryHeader.Width = table_SecondaryHeader_Width; // Secondary Header
            this.rowSecondaryHeader.Width = this.tableSecondaryHeader.Width;
            this.tableDetail.Width = table_Detail_Width;                        // Detail
            this.rowDetail.Width = this.tableDetail.Width;
            this.tableSecondaryFooter.Width = table_SecondaryFooter_Width; // Secondary Footer
            this.rowSecondaryFooter.Width = this.tableSecondaryFooter.Width;
            this.tablePrimaryFooter.Width = table_PrimaryFooter_Width;      // Primary Footer
            this.rowPrimaryFooter.Width = this.tablePrimaryFooter.Width;
            this.tableReportFooter.Width = table_ReportFooter_Width;            // Report Footer
            this.rowReportFooter.Width = this.tableReportFooter.Width;
            this.tablePageFooter.Width = table_PageFooter_Width;                // Page Footer
            this.rowPageFooter.Width = this.tablePageFooter.Width;

            #endregion

            #region Add All Tables to Bands and set Bands' Height

            if (useReportHeader) // Report Header
            {
                this.bandReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tableReportHeader });
                this.bandReportHeader.Height = table_ReportHeader_Height + table_ReportHeader_padding_Top + table_ReportHeader_padding_Bottom;
            }
            else
            {
                this.bandReportHeader.Height = 0;
            }

            if (usePageHeader) // Page Header
            {
                this.bandPageHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tablePageHeader });
                this.bandPageHeader.Height = table_PageHeader_Height + table_PageHeader_padding_Top + table_PageHeader_padding_Bottom;
            }
            else
            {
                this.bandPageHeader.Height = 0;
            }

            if (usePrimary) //Primary Header
            {
                this.bandPrimaryHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tablePrimaryHeader });
                this.bandPrimaryHeader.Height = table_PrimaryHeader_Height + table_PrimaryHeader_padding_Top + table_PrimaryHeader_padding_Bottom;
            }
            else
            {
                this.bandPrimaryHeader.Height = 0;
            }

            if (useSecondary) // Secondary Header
            {
                this.bandSecondaryHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tableSecondaryHeader });
                this.bandSecondaryHeader.Height = table_SecondaryHeader_Height + table_SecondaryHeader_padding_Top + table_SecondaryHeader_padding_Bottom;
            }
            else
            {
                this.bandSecondaryHeader.Height = 0;
            }

            if (useDetail) // Detail
            {
                this.bandDetail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tableDetail });
                this.bandDetail.Height = table_Detail_Height + table_Detail_padding_Top + table_Detail_padding_Bottom;
            }
            else
            {
                this.bandDetail.Height = 0;
            }

            if (useSecondary) //Secondary Footer
            {
                this.bandSecondaryFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tableSecondaryFooter });
                this.bandSecondaryFooter.Height = table_SecondaryFooter_Height + table_SecondaryFooter_padding_Top + table_SecondaryFooter_padding_Bottom;
            }
            else
            {
                this.bandSecondaryFooter.Height = 0;
            }

            if (usePrimary) // Primary Footer
            {
                this.bandPrimaryFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tablePrimaryFooter });
                this.bandPrimaryFooter.Height = table_PrimaryFooter_Height + table_PrimaryFooter_padding_Top + table_PrimaryFooter_padding_Bottom;
            }
            else
            {
                this.bandPrimaryFooter.Height = 0;
            }

            if (useReportFooter) // Report Footer
            {
                this.bandReportFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tableReportFooter });
                this.bandReportFooter.Height = table_ReportFooter_Height + table_ReportFooter_padding_Top + table_ReportFooter_padding_Bottom;
            }
            else
            {
                this.bandReportFooter.Height = 0;
            }

            if (usePageFooter) // Page Footer
            {
                this.bandPageFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.tablePageFooter });
                this.bandPageFooter.Height = table_PageFooter_Height + table_PageFooter_padding_Top + table_PageFooter_padding_Bottom;
            }
            else
            {
                this.bandPageFooter.Height = 0;
            }

            #endregion

            #region Analysis Report
            //
            // AnalysisReport
            //
            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
                                                                        this.bandDetail,
                                                                        this.bandPageHeader,
                                                                        this.bandPageFooter,
                                                                        this.bandPrimaryHeader,
                                                                        this.bandPrimaryFooter,
                                                                        this.bandReportFooter,
                                                                        this.bandReportHeader,
                                                                        this.bandSecondaryHeader,
                                                                        this.bandSecondaryFooter});
            this.Margins = page_Margins;
            this.PageHeight = page_Height;
            this.PageWidth = page_Width;
            this.PaperKind = paperKind;
            this.Version = "8.2";

            #endregion

            ((System.ComponentModel.ISupportInitialize)(this.tableDetail)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePageHeader)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePrimaryHeader)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePrimaryFooter)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableReportFooter)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableReportHeader)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableSecondaryHeader)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableSecondaryFooter)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tablePageFooter)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
        }

        #endregion

        private DevExpress.XtraReports.UI.ReportHeaderBand bandReportHeader;
        private DevExpress.XtraReports.UI.XRTable tableReportHeader;
        private DevExpress.XtraReports.UI.XRTableRow rowReportHeader;

        private DevExpress.XtraReports.UI.PageHeaderBand bandPageHeader;
        private DevExpress.XtraReports.UI.XRTable tablePageHeader;
        private DevExpress.XtraReports.UI.XRTableRow rowPageHeader;

        private DevExpress.XtraReports.UI.GroupHeaderBand bandPrimaryHeader;
        private DevExpress.XtraReports.UI.XRTable tablePrimaryHeader;
        private DevExpress.XtraReports.UI.XRTableRow rowPrimaryHeader;

        private DevExpress.XtraReports.UI.GroupHeaderBand bandSecondaryHeader;
        private DevExpress.XtraReports.UI.XRTable tableSecondaryHeader;
        private DevExpress.XtraReports.UI.XRTableRow rowSecondaryHeader;

        private DevExpress.XtraReports.UI.DetailBand bandDetail;
        private DevExpress.XtraReports.UI.XRTable tableDetail;
        private DevExpress.XtraReports.UI.XRTableRow rowDetail;

        private DevExpress.XtraReports.UI.GroupFooterBand bandSecondaryFooter;
        private DevExpress.XtraReports.UI.XRTable tableSecondaryFooter;
        private DevExpress.XtraReports.UI.XRTableRow rowSecondaryFooter;

        private DevExpress.XtraReports.UI.GroupFooterBand bandPrimaryFooter;
        private DevExpress.XtraReports.UI.XRTable tablePrimaryFooter;
        private DevExpress.XtraReports.UI.XRTableRow rowPrimaryFooter;

        private DevExpress.XtraReports.UI.ReportFooterBand bandReportFooter;
        private DevExpress.XtraReports.UI.XRTable tableReportFooter;
        private DevExpress.XtraReports.UI.XRTableRow rowReportFooter;

        private DevExpress.XtraReports.UI.PageFooterBand bandPageFooter;
        private DevExpress.XtraReports.UI.XRTable tablePageFooter;
        private DevExpress.XtraReports.UI.XRTableRow rowPageFooter;

        #endregion

        #region Init value

        protected Margins page_Margins = new Margins(25, 25, 25, 25);
        protected int page_Height = 1169;
        protected int page_Width = 827;
        protected PaperKind paperKind = PaperKind.Custom;
        protected int page_Padding_Left = 2;  // It's used to Recount all Controls' width when set [useColumnWidth = true]
        protected int page_Padding_Right = 2; // It's used to Recount all Controls' width when set [useColumnWidth = true]

        protected PaddingInfo _bandPaddingInfo = new PaddingInfo(2, 2, 0, 0, 100F);
        protected PaddingInfo _cellPaddingInfo = new PaddingInfo(5, 5, 0, 0, 100F);

        protected int _colWidth = 75;
        protected int _maxWidth = 777;
        protected int _minWidth = 777;

        /// <summary>
        /// True :
        /// </summary>
        protected bool useColumnWidth = true;

        protected bool useReportHeader = false;
        protected bool usePageHeader = false;
        protected bool usePrimary = false;
        protected bool useSecondary = false;
        protected bool useDetail = true;
        protected bool useReportFooter = false;
        protected bool usePageFooter = false;

        protected int table_ReportHeader_Height = 18;
        protected int table_PageHeader_Height = 18;
        protected int table_PrimaryHeader_Height = 18;
        protected int table_SecondaryHeader_Height = 18;
        protected int table_Detail_Height = 18;
        protected int table_SecondaryFooter_Height = 18;
        protected int table_PrimaryFooter_Height = 18;
        protected int table_ReportFooter_Height = 25;
        protected int table_PageFooter_Height = 25;
        protected int table_Height
        {
            set
            {
                if (value < 0)
                    value = 0;

                table_ReportHeader_Height = value;
                table_PageHeader_Height = value;
                table_PrimaryHeader_Height = value;
                table_SecondaryHeader_Height = value;
                table_Detail_Height = value;
                table_SecondaryFooter_Height = value;
                table_PrimaryFooter_Height = value;
                table_ReportFooter_Height = value;
                table_PageFooter_Height = value;
            }
        }

        protected int table_ReportHeader_Width = 773;
        protected int table_PageHeader_Width = 773;
        protected int table_PrimaryHeader_Width = 773;
        protected int table_SecondaryHeader_Width = 773;
        protected int table_Detail_Width = 773;
        protected int table_SecondaryFooter_Width = 773;
        protected int table_PrimaryFooter_Width = 773;
        protected int table_ReportFooter_Width = 773;
        protected int table_PageFooter_Width = 773;
        protected int table_Width
        {
            set
            {
                if (value < 0)
                    value = 0;

                table_ReportHeader_Width = value;
                table_PageHeader_Width = value;
                table_PrimaryHeader_Width = value;
                table_SecondaryHeader_Width = value;
                table_Detail_Width = value;
                table_SecondaryFooter_Width = value;
                table_PrimaryFooter_Width = value;
                table_ReportFooter_Width = value;
                table_PageFooter_Width = value;
            }
        }

        protected int table_ReportHeader_padding_Top = 0;
        protected int table_ReportHeader_padding_Bottom = 0;
        protected int table_ReportHeader_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_ReportHeader_padding_Top = value;
                table_ReportHeader_padding_Bottom = value;
            }
        }

        protected int table_PageHeader_padding_Top = 0;
        protected int table_PageHeader_padding_Bottom = 0;
        protected int table_PageHeader_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_PageHeader_padding_Top = value;
                table_PageHeader_padding_Bottom = value;
            }
        }

        protected int table_PrimaryHeader_padding_Top = 5;
        protected int table_PrimaryHeader_padding_Bottom = 5;
        protected int table_PrimaryHeader_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_PrimaryHeader_padding_Top = value;
                table_PrimaryHeader_padding_Bottom = value;
            }
        }

        protected int table_SecondaryHeader_padding_Top = 5;
        protected int table_SecondaryHeader_padding_Bottom = 5;
        protected int table_SecondaryHeader_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_SecondaryHeader_padding_Top = value;
                table_SecondaryHeader_padding_Bottom = value;
            }
        }

        protected int table_Detail_padding_Top = 0;
        protected int table_Detail_padding_Bottom = 0;
        protected int table_Detail_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_Detail_padding_Top = value;
                table_Detail_padding_Bottom = value;
            }
        }

        protected int table_SecondaryFooter_padding_Top = 2;
        protected int table_SecondaryFooter_padding_Bottom = 2;
        protected int table_SecondaryFooter_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_SecondaryFooter_padding_Top = value;
                table_SecondaryFooter_padding_Bottom = value;
            }
        }

        protected int table_PrimaryFooter_padding_Top = 2;
        protected int table_PrimaryFooter_padding_Bottom = 2;
        protected int table_PrimaryFooter_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_PrimaryFooter_padding_Top = value;
                table_PrimaryFooter_padding_Bottom = value;
            }
        }

        protected int table_ReportFooter_padding_Top = 5;
        protected int table_ReportFooter_padding_Bottom = 5;
        protected int table_ReportFooter_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_ReportFooter_padding_Top = value;
                table_ReportFooter_padding_Bottom = value;
            }
        }

        protected int table_PageFooter_padding_Top = 5;
        protected int table_PageFooter_padding_Bottom = 5;
        protected int table_PageFooter_padding
        {
            set
            {
                if (value < 0)
                    value = 0;
                table_PageFooter_padding_Top = value;
                table_PageFooter_padding_Bottom = value;
            }
        }
        protected int table_Padding_Top
        {
            set
            {
                if (value < 0)
                    value = 0;

                table_ReportHeader_padding_Top = value;
                table_PageHeader_padding_Top = value;
                table_PrimaryHeader_padding_Top = value;
                table_SecondaryHeader_padding_Top = value;
                table_Detail_padding_Top = value;
                table_SecondaryFooter_padding_Top = value;
                table_PrimaryFooter_padding_Top = value;
                table_ReportFooter_padding_Top = value;
                table_PageFooter_padding_Top = value;
            }
        }
        protected int table_Padding_Bottom
        {
            set
            {
                if (value < 0)
                    value = 0;

                table_ReportHeader_padding_Bottom = value;
                table_PageHeader_padding_Bottom = value;
                table_PrimaryHeader_padding_Bottom = value;
                table_SecondaryHeader_padding_Bottom = value;
                table_Detail_padding_Bottom = value;
                table_SecondaryFooter_padding_Bottom = value;
                table_PrimaryFooter_padding_Bottom = value;
                table_ReportFooter_padding_Bottom = value;
                table_PageFooter_padding_Bottom = value;
            }
        }

        protected Font cell_ReportHeader_Font = new Font("Times New Roman", 9.5F);
        protected Font cell_PageHeader_Font = new Font("Times New Roman", 9.5F);
        protected Font cell_PrimaryHeader_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_SecondaryHeader_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_Detail_Font = new Font("Times New Roman", 9.5F);
        protected Font cell_SecondaryFooter_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_PrimaryFooter_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_ReportFooter_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_PageFooter_Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold);
        protected Font cell_Font
        {
            set
            {
                cell_ReportHeader_Font = value;
                cell_PageHeader_Font = value;
                cell_PrimaryHeader_Font = value;
                cell_SecondaryHeader_Font = value;
                cell_Detail_Font = value;
                cell_SecondaryFooter_Font = value;
                cell_PrimaryFooter_Font = value;
                cell_ReportFooter_Font = value;
                cell_PageFooter_Font = value;
            }
        }


        //
        // Tables Location : (page_Padding_Left,table_Padding_Top)
        //
        protected System.Drawing.Point table_ReportHeader_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_ReportHeader_padding_Top); }
        }
        protected System.Drawing.Point table_PageHeader_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_PageHeader_padding_Top); }
        }
        protected System.Drawing.Point table_PrimaryHeader_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_PrimaryHeader_padding_Top); }
        }
        protected System.Drawing.Point table_SecondaryHeader_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_SecondaryHeader_padding_Top); }
        }
        protected System.Drawing.Point table_Detail_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_Detail_padding_Top); }
        }
        protected System.Drawing.Point table_SecondaryFooter_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_SecondaryFooter_padding_Top); }
        }
        protected System.Drawing.Point table_PrimaryFooter_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_PrimaryFooter_padding_Top); }
        }
        protected System.Drawing.Point table_ReportFooter_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_ReportFooter_padding_Top); }
        }
        protected System.Drawing.Point table_PageFooter_Location
        {
            get { return new System.Drawing.Point(page_Padding_Left, table_PageFooter_padding_Top); }
        }

        #endregion

        DataTable _dataTable = null;
        DataSet _dataSet = null;
        AnalysisReportAnalysisList source = null;
        public AnalysisReport(object data)
        {
            source = data as AnalysisReportAnalysisList;
            if (source == null || source.DataSet == null || source.DataSet.Tables.Count <= 0)
                return;

            _dataSet = source.DataSet;
            _dataTable = source.DataSet.Tables[0];

            this.DataSource = _dataSet;
            this.DataMember = _dataSet.Tables[0].TableName;

            InitStyles();
            InitializeComponent();
            this.ShowPreviewDialog();

            //xrTableReportHeader.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableReportHeader_BeforePrint);
            //xrTablePageHeader.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTablePageHeader_BeforePrint);
            //xrTableGroupHeaderSecondary.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableGroupHeader2_BeforePrint);
            //xrTableGroupHeaderPrimary.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableGroupHeader1_BeforePrint);
            //xrTableDetail.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableDetail_BeforePrint);
            //xrTableGroupFooterPrimary.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableGroupFooter1_BeforePrint);
            //xrTableGroupFooterSecondary.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableGroupFooter2_BeforePrint);
            //xrTableReportFooter.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTableReportFooter_BeforePrint);
            //xrTablePageFooter.BeforePrint += new System.Drawing.Printing.PrintEventHandler(xrTablePageFooter_BeforePrint);
        }

        #region IReport Members


        public void ShowData(object data)
        {
            //source = data as AnalysisReportAnalysisList;
            //this.DataSource = source;
        }

        #endregion

        #region IReportLayout Members

        public byte EntityType
        {
            get { return (byte)_eType; }
        }

        public MasterSoft.Shared.Reporting.Enums.Language Language
        {
            get { return MasterSoft.Shared.Reporting.Enums.Language.English; }
        }

        string IReportLayout.Name
        {
            get { return "Analysis Report"; }
        }

        #endregion

        private static BLL.ReportEntities.EntityTypes _eType = BLL.ReportEntities.EntityTypes.Analysis;

        public static void TryPreview(object data)
        {
            TryPreview(data, false);
        }

        public static void TryPreview(object data, bool forceUpdate)
        {
            new AnalysisReport(data);
            //MasterSoft.Shared.Reporting.Report.SaveSource(new AnalysisReport(data), forceUpdate);
            //SimplePreview.Instance.ShowForm(data, (byte)_eType, false);
        }

        public void InitStyles()
        {
            XRControlStyle style1 = new XRControlStyle();
            XRControlStyle style2 = new XRControlStyle();

            style1.BackColor = Color.LightBlue;
            style1.StyleUsing.UseBackColor = true;
            style1.StyleUsing.UseBorders = false;
            style1.Name = "Style1";


            style2.BackColor = Color.LightPink;
            style2.StyleUsing.UseBackColor = true;
            style2.StyleUsing.UseBorders = false;
            style2.Name = "Style1";

            this.StyleSheet.AddRange(new DevExpress.XtraReports.UI.XRControlStyle[] { style1, style2 });
        }

        /// <summary>
        /// Init Properties values in the method
        /// </summary>
        private void InitPropertyValue()
        { }

        /// <summary>
        /// Init All Bands in this method.
        /// </summary>
        private void InitBands()
        {
            int _colTotalCount = _dataTable.Columns.Count;
            int _colSelectCount = source.FieldAlias.Length;

            Type _colDataType;

            if (useColumnWidth)
            {
                _maxWidth = 0;
                _colWidth = 75;
            }
            else // Use Page's Width
            {
                _maxWidth = page_Width - page_Margins.Left - page_Margins.Right;
                _colWidth = _maxWidth / _colSelectCount;
            }

            for (int i = 0; i < _colSelectCount; i++) //Only bind the select field by traverse [source.FieldAlias]
            {
                for (int j = 0; j < _colTotalCount; j++)
                {
                    string currentColCaption = _dataTable.Columns[j].Caption;

                    if (source.SummaryOnly
                        && !source.FieldProperty[i, 0]
                        && source.PrimaryAlias != currentColCaption
                        && source.SecondaryAlias != currentColCaption) // Summary Only and Current Column isn't a Calc Field or Primary Field or Secondary Field
                        continue;

                    if (source.FieldAlias[i] != currentColCaption) // No Equal then turn to next
                        continue;

                    _colDataType = _dataTable.Columns[j].DataType;

                    if (useColumnWidth)
                    {
                        _colWidth = getCellWidth(_colDataType);
                        _maxWidth += _colWidth;
                    }

                    #region Report Header

                    #endregion

                    #region Page Header

                    XRTableCell cellPageHeader = getNewCell(BandType.PageHeader, _colWidth, _colDataType);

                    cellPageHeader.Text = BLL.Common.ReportHelper.ReportHeader(source.Header[i]);

                    //***** First Cell
                    if (rowPageHeader.Cells.Count == 0)
                        cellPageHeader.Borders = DevExpress.XtraPrinting.BorderSide.Left
                                               | DevExpress.XtraPrinting.BorderSide.Top
                                               | DevExpress.XtraPrinting.BorderSide.Bottom;
                    //***** Other cells
                    else
                        cellPageHeader.Borders = DevExpress.XtraPrinting.BorderSide.Right
                                               | DevExpress.XtraPrinting.BorderSide.Top
                                               | DevExpress.XtraPrinting.BorderSide.Bottom;

                    //***** it Has more than two cells before add Currenct Cell
                    //***** The cells only have Top border and Bottom border except first cell
                    if (rowPageHeader.Cells.Count > 1)
                    {
                        rowPageHeader.Cells[rowPageHeader.Cells.Count - 1].Borders = DevExpress.XtraPrinting.BorderSide.Top
                                                                                   | DevExpress.XtraPrinting.BorderSide.Bottom;
                    }

                    rowPageHeader.Cells.Add(cellPageHeader);
                    usePageHeader = true;

                    #endregion

                    #region Primary Header

                    XRTableCell cellPrimaryHeader = getNewCell(BandType.PrimaryHeader, _colWidth, _colDataType);

                    if (rowPrimaryHeader.Cells.Count < 1)  //Only Add one cell.
                        rowPrimaryHeader.Cells.Add(cellPrimaryHeader);
                    else
                        cellPrimaryHeader = rowPrimaryHeader.Cells[0];

                    if (source.PrimaryAlias == currentColCaption)
                    {
                        addGroupField(bandPrimaryHeader, source.FieldAlias[i], source.PrimaryAlias == source.OrderByAlias ? source.IsAsc : true);

                        cellPrimaryHeader.DataBindings.Add("Text",
                                                            null,
                                                            source.FieldAlias[i],
                                                            getFormatString(_colDataType, string.Format("{0} :  ", source.Header[i]), string.Empty));
                        cellPrimaryHeader.Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold | FontStyle.Underline);
                        usePrimary = true;
                    }

                    #endregion

                    #region Secondary Header

                    XRTableCell cellSecondaryHeader = getNewCell(BandType.SecondaryHeader, _colWidth, _colDataType);

                    if (rowSecondaryHeader.Cells.Count < 1)  // Only add one cell.
                        rowSecondaryHeader.Cells.Add(cellSecondaryHeader);
                    else
                        cellSecondaryHeader = rowSecondaryHeader.Cells[0];

                    if (source.SecondaryAlias != source.PrimaryAlias && source.SecondaryAlias == currentColCaption)
                    {
                        addGroupField(bandSecondaryHeader, source.FieldAlias[i], source.SecondaryAlias == source.OrderByAlias ? source.IsAsc : true);

                        cellSecondaryHeader.Padding = new PaddingInfo(50, 0, 0, 0, 100F);
                        cellSecondaryHeader.DataBindings.Add("Text",
                                                              null,
                                                              source.FieldAlias[i],
                                                              getFormatString(_colDataType, string.Format("{0} :  ", source.Header[i]), string.Empty));
                        cellSecondaryHeader.Font = new Font("Times New Roman", 9.5F, System.Drawing.FontStyle.Bold | FontStyle.Underline);
                        useSecondary = true;
                    }

                    #endregion

                    #region Detail

                    tableDetail.EvenStyleName = "Style1";
                    tableDetail.OddStyleName = "Style2";

                    XRTableCell cellDetail = getNewCell(BandType.Detail, _colWidth, _colDataType);

                    cellDetail.DataBindings.Add("Text", null, source.FieldAlias[i], getFormatString(_colDataType));

                    rowDetail.Cells.Add(cellDetail);
                    useDetail = !source.SummaryOnly;

                    #endregion

                    #region Secondary Footer

                    XRTableCell cellSecondaryFooter = getNewCell(BandType.SecondaryFooter, _colWidth, _colDataType);

                    if (source.FieldProperty[i, 0]) // It's a Calc Field
                    {
                        cellSecondaryFooter.BorderWidth = 1;
                        cellSecondaryFooter.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;

                        cellSecondaryFooter.DataBindings.Add("Text", null, source.FieldAlias[i], getFormatString(_colDataType));
                        cellSecondaryFooter.Summary = getSummary(getFormatString(_colDataType), DevExpress.XtraReports.UI.SummaryRunning.Group);
                    }
                    rowSecondaryFooter.Cells.Add(cellSecondaryFooter);

                    #endregion

                    #region Primary Footer

                    XRTableCell cellPrimaryFooter = getNewCell(BandType.PrimaryFooter, _colWidth, _colDataType);

                    if (source.FieldProperty[i, 0]) // It's a Calc Field
                    {
                        cellPrimaryFooter.BorderWidth = 1;
                        cellPrimaryFooter.Borders = DevExpress.XtraPrinting.BorderSide.Bottom;

                        cellPrimaryFooter.DataBindings.Add("Text", null, source.FieldAlias[i], getFormatString(_colDataType));
                        cellPrimaryFooter.Summary = getSummary(getFormatString(_colDataType), DevExpress.XtraReports.UI.SummaryRunning.Group);
                    }
                    rowPrimaryFooter.Cells.Add(cellPrimaryFooter);

                    #endregion

                    #region Report Footer

                    XRTableCell cellReportFooter = getNewCell(BandType.ReportFooter, _colWidth, _colDataType);

                    cellReportFooter.BorderWidth = 1;
                    cellReportFooter.Borders = DevExpress.XtraPrinting.BorderSide.Top;

                    if (source.FieldProperty[i, 0]) // It's a Calc Field
                    {
                        cellReportFooter.Borders = DevExpress.XtraPrinting.BorderSide.Top
                                                 | DevExpress.XtraPrinting.BorderSide.Bottom;

                        cellReportFooter.DataBindings.Add("Text", null, source.FieldAlias[i], getFormatString(_colDataType));
                        cellReportFooter.Summary = getSummary(getFormatString(_colDataType), DevExpress.XtraReports.UI.SummaryRunning.Report);
                    }
                    rowReportFooter.Cells.Add(cellReportFooter);
                    useReportFooter = true;

                    #endregion

                    #region Page Footer

                    #endregion

                    break; // Found the match Column then break out
                }/// for
            }/// for

            #region maxWidth less than minWidth

            if (_maxWidth < _minWidth)
            {
                int cellWidth = _minWidth - _maxWidth;

                if (rowPageHeader.Cells.Count > 1)// when it have more cells, the cells between first cell and last cell will only have Top border and Bottom border
                    rowPageHeader.Cells[rowPageHeader.Cells.Count - 1].Borders = BorderSide.Top | BorderSide.Bottom;

                rowPageHeader.Cells.Add(getNewCell(BandType.PageHeader, cellWidth, null));
                rowPageHeader.Cells[rowPageHeader.Cells.Count - 1].Borders = BorderSide.Top | BorderSide.Bottom | BorderSide.Right;

                rowDetail.Cells.Add(getNewCell(BandType.Detail, cellWidth, null));
                rowSecondaryFooter.Cells.Add(getNewCell(BandType.SecondaryFooter, cellWidth, null));
                rowPrimaryFooter.Cells.Add(getNewCell(BandType.PrimaryFooter, cellWidth, null));
                rowReportFooter.Cells.Add(getNewCell(BandType.ReportFooter, cellWidth, null));
            }

            #endregion
        }

        #region Method

        private XRTableCell getNewCell(BandType bandType, int width, Type dataType)
        {
            XRTableCell cell = new XRTableCell();
            cell.Width = width;

            switch (bandType)
            {
                case BandType.ReportHeader:
                    break;
                case BandType.PageHeader:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowPageHeader.Height,
                                        cell_PageHeader_Font,
                                        getTextAlignment(dataType, Position_V.Top),
                                        1,
                                        BorderSide.None);
                case BandType.PrimaryHeader:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowPrimaryHeader.Height,
                                        cell_PrimaryHeader_Font,
                                        getTextAlignment(dataType, Position_V.Top),
                                        0,
                                        BorderSide.None);
                case BandType.SecondaryHeader:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowSecondaryHeader.Height,
                                        cell_SecondaryHeader_Font,
                                        getTextAlignment(dataType, Position_V.Top),
                                        0,
                                        BorderSide.Bottom);
                case BandType.Detail:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowDetail.Height,
                                        cell_Detail_Font,
                                        getTextAlignment(dataType, Position_V.Top),
                                        0,
                                        BorderSide.None);
                case BandType.SecondaryFooter:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowSecondaryFooter.Height,
                                        cell_SecondaryFooter_Font,
                                        getTextAlignment(dataType, Position_V.Middle),
                                        0,
                                        BorderSide.None);
                case BandType.PrimaryFooter:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowPrimaryFooter.Height,
                                        cell_PrimaryFooter_Font,
                                        getTextAlignment(dataType, Position_V.Middle),
                                        0,
                                        BorderSide.None);
                case BandType.ReportFooter:
                    return getNewCell(_cellPaddingInfo,
                                        width,
                                        rowReportFooter.Height,
                                        cell_ReportFooter_Font,
                                        getTextAlignment(dataType, Position_V.Middle),
                                        0,
                                        BorderSide.None);
                case BandType.PageFooter:
                    break;
                default:
                    break;
            }
            return cell;
        }

        /// <summary>
        /// Return New Cell
        /// </summary>
        /// <param name="paddingInfo">Cell's Padding Info</param>
        /// <param name="width">Cell's Width</param>
        /// <param name="height">Cell's Height</param>
        /// <param name="font">Cell's Font</param>
        /// <param name="textAlign">Cell's Text Alignment</param>
        /// <param name="borderWidth">Cell's Border Width</param>
        /// <param name="borderSide">Cell's Border Side</param>
        /// <returns>Return New Cell</returns>
        private XRTableCell getNewCell(PaddingInfo paddingInfo, int width, int height, Font font, TextAlignment textAlign, int borderWidth, BorderSide borderSide)
        {
            XRTableCell cell = new XRTableCell();
            cell.Text = string.Empty;
            cell.Padding = paddingInfo;
            cell.Width = width;
            cell.Height = height;
            cell.Font = font;
            cell.TextAlignment = textAlign;
            cell.BorderWidth = borderWidth;
            cell.Borders = borderSide;

            return cell;
        }

        private void addGroupField(GroupHeaderBand band, string field)
        {
            band.GroupFields.AddRange(new DevExpress.XtraReports.UI.GroupField[] {
                new GroupField(field) });
        }

        private void addGroupField(GroupHeaderBand band, string field, bool isAsc)
        {
            band.GroupFields.AddRange(new DevExpress.XtraReports.UI.GroupField[] {
                new GroupField(field, isAsc ? XRColumnSortOrder.Ascending : XRColumnSortOrder.Descending) });
        }

        private XRSummary getSummary(string formatString, DevExpress.XtraReports.UI.SummaryRunning runningType)
        {
            XRSummary summary = new XRSummary();
            summary.FormatString = formatString;
            summary.Running = runningType;

            return summary;
        }

        private string getFormatString(Type type, string prefix, string suffix)
        {
            return string.Format("{0}{1}{2}", prefix, getFormatString(type), suffix);
        }

        private string getFormatString(Type type)
        {
            if (type == null)
                return "";

            string typeString = type.FullName;

            if (typeString == typeof(Byte).ToString()
             || typeString == typeof(Char).ToString()
             || typeString == typeof(Boolean).ToString()
             || typeString == typeof(String).ToString())
                return "{0:#}";

            else if (typeString == typeof(Int16).ToString()
                  || typeString == typeof(Int32).ToString()
                  || typeString == typeof(Int64).ToString())
                return "{0:#,#}";

            else if (typeString == typeof(Double).ToString()
                  || typeString == typeof(Decimal).ToString())
                return "{0:#,#.00}";

            else if (typeString == typeof(SmartDate).ToString())
                return UniversalValue.DateFormat.DDMMYYYY;//"{0:yyyy-MM-dd}";

            else if (typeString == typeof(DateTime).ToString())
                return "{0:" + UniversalValue.DateFormat.DDMMYYYY + "}";//"{0:yyyy-MM-dd HH:mm:ss}";

            else
                return "";
        }

        private int getCellWidth(Type type)
        {
            if (type == null)
                return 75;

            string typeString = type.FullName;

            if (typeString == typeof(Byte).ToString()
             || typeString == typeof(Char).ToString()
             || typeString == typeof(Boolean).ToString())
                return 25;

            else if (typeString == typeof(String).ToString())
                return 150;

            else if (typeString == typeof(Int16).ToString()
                  || typeString == typeof(Int32).ToString()
                  || typeString == typeof(Int64).ToString())
                return 60;

            else if (typeString == typeof(Double).ToString()
                  || typeString == typeof(Decimal).ToString())
                return 80;

            else if (typeString == typeof(SmartDate).ToString())
                return 80;

            else if (typeString == typeof(DateTime).ToString())
                return 80;

            else
                return 75;

        }

        private TextAlignment getTextAlignment(Type type, Position_V position_V)
        {
            Position_H position_H = getPosition_H(type);

            switch (position_V)
            {
                case Position_V.Top:
                    switch (position_H)
                    {
                        case Position_H.Left:
                            return TextAlignment.TopLeft;
                        case Position_H.Center:
                            return TextAlignment.TopCenter;
                        case Position_H.Right:
                            return TextAlignment.TopRight;
                        default:
                            return TextAlignment.TopLeft;
                    }
                case Position_V.Middle:
                    switch (position_H)
                    {
                        case Position_H.Left:
                            return TextAlignment.MiddleLeft;
                        case Position_H.Center:
                            return TextAlignment.MiddleCenter;
                        case Position_H.Right:
                            return TextAlignment.MiddleRight;
                        default:
                            return TextAlignment.MiddleLeft;
                    }
                case Position_V.Bottom:
                    switch (position_H)
                    {
                        case Position_H.Left:
                            return TextAlignment.BottomLeft;
                        case Position_H.Center:
                            return TextAlignment.BottomCenter;
                        case Position_H.Right:
                            return TextAlignment.BottomRight;
                        default:
                            return TextAlignment.BottomLeft;
                    }
                default:
                    return TextAlignment.TopLeft;
            }
        }

        private Position_H getPosition_H(Type type)
        {
            if (type == null)
                return Position_H.Left;

            string typeString = type.FullName;

            if (typeString == typeof(Byte).ToString()
             || typeString == typeof(Char).ToString()
             || typeString == typeof(Boolean).ToString())
                return Position_H.Center;

            else if (typeString == typeof(String).ToString())
                return Position_H.Left;

            else if (typeString == typeof(Int16).ToString()
                  || typeString == typeof(Int32).ToString()
                  || typeString == typeof(Int64).ToString())
                return Position_H.Right;

            else if (typeString == typeof(Double).ToString()
                  || typeString == typeof(Decimal).ToString())
                return Position_H.Right;

            else if (typeString == typeof(SmartDate).ToString()
                  || typeString == typeof(DateTime).ToString())
                return Position_H.Left;

            else
                return Position_H.Left;
        }

        private enum Position_H
        {
            Left,
            Center,
            Right
        }

        private enum Position_V
        {
            Top,
            Middle,
            Bottom
        }

        private enum BandType
        {
            ReportHeader,
            PageHeader,
            PrimaryHeader,
            SecondaryHeader,
            Detail,
            SecondaryFooter,
            PrimaryFooter,
            ReportFooter,
            PageFooter
        }

        #endregion
    }
}

原创粉丝点击