Exemple #1
0
        private void LoadSubBand(XmlNode node, Base parent)
        {
            ChildBand child = ComponentsFactory.CreateChildBand(parent as BandBase);

            LoadBand(node, child);
            LoadObjects(node, child);
        }
Exemple #2
0
        /// <summary>
        /// Creates a ChildBand instance in the specified BandBase.
        /// </summary>
        /// <param name="parent">The BandBase instance.</param>
        /// <returns>The ChildBand instance.</returns>
        public static ChildBand CreateChildBand(BandBase parent)
        {
            ChildBand child = new ChildBand();

            parent.AddChild(child);
            child.CreateUniqueName();
            return(child);
        }
Exemple #3
0
        private void ShowBand(BandBase band, bool getData)
        {
            if (band == null)
            {
                return;
            }

            BandBase saveCurBand = curBand;

            curBand = band;

            try
            {
                // do we need to keep child?
                ChildBand child     = band.Child;
                bool      showChild = child != null && !(band is DataBand && child.CompleteToNRows > 0) && !child.FillUnusedSpace &&
                                      !(band is DataBand && child.PrintIfDatabandEmpty);
                if (showChild && band.KeepChild)
                {
                    StartKeep(band);
                }

                if (outputBand != null)
                {
                    AddToOutputBand(band, getData);
                }
                else
                {
                    ShowBandToPreparedPages(band, getData);
                }

                ProcessTotals(band);
                if (band.Visible)
                {
                    RenderOuterSubreports(band);
                }

                // show child band. Skip if child is used to fill empty space: it was processed already
                if (showChild)
                {
                    ShowBand(child);
                    if (band.KeepChild)
                    {
                        EndKeep();
                    }
                }
            }
            finally
            {
                curBand = saveCurBand;
            }
        }
        private void btnUp_Click(object sender, EventArgs e)
        {
            BandBase band = tvBands.SelectedNode.Tag as BandBase;

            if (band.Parent == Page || band is DataBand)
            {
                band.ZOrder--;
            }
            else if (band is ChildBand && band.Parent is ChildBand)
            {
                ChildBand parent    = band.Parent as ChildBand;
                BandBase  newParent = parent.Parent as BandBase;
                parent.Parent = null;
                band.Parent   = newParent;
                parent.Child  = band.Child;
                band.Child    = parent;
            }
            else if (band is GroupHeaderBand && band.Parent is GroupHeaderBand)
            {
                GroupHeaderBand group     = band as GroupHeaderBand;
                GroupHeaderBand parent    = band.Parent as GroupHeaderBand;
                Base            newParent = parent.Parent;
                BandBase        child     = null;
                if (group.Data != null)
                {
                    child = group.Data;
                }
                else
                {
                    child = group.NestedGroup;
                }
                int zOrder = parent.ZOrder;
                parent.Parent = null;
                group.Parent  = newParent;
                group.ZOrder  = zOrder;
                child.Parent  = parent;
                parent.Parent = group;
            }
            Change();
        }
        private void btnDown_Click(object sender, EventArgs e)
        {
            BandBase band = tvBands.SelectedNode.Tag as BandBase;

            if (band is DataBand)
            {
                band.ZOrder += 2;
            }
            else if (band is ChildBand && band.Child != null)
            {
                BandBase  parent = band.Parent as BandBase;
                ChildBand child  = band.Child;
                band.Parent  = null;
                child.Parent = parent;
                band.Child   = child.Child;
                band.Parent  = child;
            }
            else if (band is GroupHeaderBand && (band as GroupHeaderBand).NestedGroup != null)
            {
                GroupHeaderBand group  = band as GroupHeaderBand;
                Base            parent = band.Parent;
                GroupHeaderBand child  = group.NestedGroup;
                int             zOrder = group.ZOrder;
                group.Parent = null;
                child.Parent = parent;
                child.ZOrder = zOrder;
                if (child.Data != null)
                {
                    group.Data = child.Data;
                }
                else
                {
                    group.NestedGroup = child.NestedGroup;
                }
                group.Parent = child;
            }
            Change();
        }
Exemple #6
0
        private void RunDataBand(DataBand dataBand, int rowCount, bool keepFirstRow, bool keepLastRow)
        {
            if (dataBand.IsHierarchical)
            {
                ShowHierarchy(dataBand, rowCount);
                return;
            }

            bool isFirstRow      = true;
            bool someRowsPrinted = false;

            dataBand.RowNo      = 0;
            dataBand.IsFirstRow = false;
            dataBand.IsLastRow  = false;

            // check if we have only one data row that should be kept with both header and footer
            bool oneRow = rowCount == 1 && keepFirstRow && keepLastRow;

            // cycle through records
            for (int i = 0; i < rowCount; i++)
            {
                bool isLastRow = i == rowCount - 1;
                if (!dataBand.IsDetailEmpty())
                {
                    dataBand.RowNo++;
                    dataBand.AbsRowNo++;
                    dataBand.IsFirstRow = isFirstRow;
                    dataBand.IsLastRow  = isLastRow;

                    // keep header
                    if (isFirstRow && keepFirstRow)
                    {
                        StartKeep(dataBand);
                    }

                    // keep together
                    if (isFirstRow && dataBand.KeepTogether)
                    {
                        StartKeep(dataBand);
                    }

                    // keep detail
                    if (dataBand.KeepDetail)
                    {
                        StartKeep(dataBand);
                    }

                    // show header
                    if (isFirstRow)
                    {
                        ShowDataHeader(dataBand);
                    }

                    // keep footer
                    if (isLastRow && keepLastRow && dataBand.IsDeepmostDataBand)
                    {
                        StartKeep(dataBand);
                    }

                    // start block event
                    if (isFirstRow)
                    {
                        OnStateChanged(dataBand, EngineState.BlockStarted);
                    }

                    // show band
                    ShowDataBand(dataBand, rowCount);

                    // end keep header
                    if (isFirstRow && keepFirstRow && !oneRow)
                    {
                        EndKeep();
                    }

                    // end keep footer
                    if (isLastRow && keepLastRow && dataBand.IsDeepmostDataBand)
                    {
                        CheckKeepFooter(dataBand);
                    }

                    // show sub-bands
                    RunBands(dataBand.Bands);

                    // up the outline
                    OutlineUp(dataBand);

                    // end keep detail
                    if (dataBand.KeepDetail)
                    {
                        EndKeep();
                    }

                    isFirstRow      = false;
                    someRowsPrinted = true;

                    if (dataBand.Columns.Count > 1)
                    {
                        break;
                    }
                }

                dataBand.DataSource.Next();
                if (Report.Aborted)
                {
                    break;
                }
            }

            // complete upto N rows
            ChildBand child = dataBand.Child;

            if (child != null && child.CompleteToNRows > rowCount)
            {
                for (int i = 0; i < child.CompleteToNRows - rowCount; i++)
                {
                    child.RowNo    = rowCount + i + 1;
                    child.AbsRowNo = rowCount + i + 1;
                    ShowBand(child);
                }
            }
            // print child if databand is empty
            if (child != null && child.PrintIfDatabandEmpty && dataBand.IsDatasourceEmpty)
            {
                ShowBand(child);
            }

            if (someRowsPrinted)
            {
                // finish block event
                OnStateChanged(dataBand, EngineState.BlockFinished);

                // show footer
                ShowDataFooter(dataBand);

                // end KeepTogether
                if (dataBand.KeepTogether)
                {
                    EndKeep();
                }

                // end KeepLastRow
                if (keepLastRow)
                {
                    EndKeep();
                }
            }
        }
Exemple #7
0
        static Report GetSubreportReport()
        {
            Report report = new Report();

            // load nwind database
            DataSet dataSet = new DataSet();

            dataSet.ReadXml(inFolder + "\\nwind.xml");

            // register all data tables and relations
            report.RegisterData(dataSet);

            // enable the "Products" and "Suppliers" tables to use it in the report
            report.GetDataSource("Products").Enabled  = true;
            report.GetDataSource("Suppliers").Enabled = true;

            // add report page
            ReportPage page = new ReportPage();

            report.Pages.Add(page);
            // always give names to objects you create. You can use CreateUniqueName method to do this;
            // call it after the object is added to a report.
            page.CreateUniqueName();

            // create title band
            page.ReportTitle = new ReportTitleBand();
            // native FastReport unit is screen pixel, use conversion
            page.ReportTitle.Height = Units.Centimeters * 1;
            page.ReportTitle.CreateUniqueName();

            // create two title text objects
            TextObject titleText1 = new TextObject();

            titleText1.Parent = page.ReportTitle;
            titleText1.CreateUniqueName();
            titleText1.Bounds    = new RectangleF(0, 0, Units.Centimeters * 8, Units.Centimeters * 1);
            titleText1.Font      = new Font("Arial", 14, FontStyle.Bold);
            titleText1.Text      = "Products";
            titleText1.HorzAlign = HorzAlign.Center;

            TextObject titleText2 = new TextObject();

            titleText2.Parent = page.ReportTitle;
            titleText2.CreateUniqueName();
            titleText2.Bounds    = new RectangleF(Units.Centimeters * 9, 0, Units.Centimeters * 8, Units.Centimeters * 1);
            titleText2.Font      = new Font("Arial", 14, FontStyle.Bold);
            titleText2.Text      = "Suppliers";
            titleText2.HorzAlign = HorzAlign.Center;

            // create report title's child band that will contain subreports
            ChildBand childBand = new ChildBand();

            page.ReportTitle.Child = childBand;
            childBand.CreateUniqueName();
            childBand.Height = Units.Centimeters * 0.5f;

            // create the first subreport
            SubreportObject subreport1 = new SubreportObject();

            subreport1.Parent = childBand;
            subreport1.CreateUniqueName();
            subreport1.Bounds = new RectangleF(0, 0, Units.Centimeters * 8, Units.Centimeters * 0.5f);

            // create subreport's page
            ReportPage subreportPage1 = new ReportPage();

            report.Pages.Add(subreportPage1);
            // connect subreport to page
            subreport1.ReportPage = subreportPage1;

            // create report on the subreport's page
            DataBand dataBand = new DataBand();

            subreportPage1.Bands.Add(dataBand);
            dataBand.CreateUniqueName();
            dataBand.DataSource = report.GetDataSource("Products");
            dataBand.Height     = Units.Centimeters * 0.5f;

            TextObject productText = new TextObject();

            productText.Parent = dataBand;
            productText.CreateUniqueName();
            productText.Bounds = new RectangleF(0, 0, Units.Centimeters * 8, Units.Centimeters * 0.5f);
            productText.Text   = "[Products.ProductName]";


            // create the second subreport
            SubreportObject subreport2 = new SubreportObject();

            subreport2.Parent = childBand;
            subreport2.CreateUniqueName();
            subreport2.Bounds = new RectangleF(Units.Centimeters * 9, 0, Units.Centimeters * 8, Units.Centimeters * 0.5f);

            // create subreport's page
            ReportPage subreportPage2 = new ReportPage();

            report.Pages.Add(subreportPage2);
            // connect subreport to page
            subreport2.ReportPage = subreportPage2;

            // create report on the subreport's page
            DataBand dataBand2 = new DataBand();

            subreportPage2.Bands.Add(dataBand2);
            dataBand2.CreateUniqueName();
            dataBand2.DataSource = report.GetDataSource("Suppliers");
            dataBand2.Height     = Units.Centimeters * 0.5f;

            // create supplier name text
            TextObject supplierText = new TextObject();

            supplierText.Parent = dataBand2;
            supplierText.CreateUniqueName();
            supplierText.Bounds = new RectangleF(0, 0, Units.Centimeters * 8, Units.Centimeters * 0.5f);
            supplierText.Text   = "[Suppliers.CompanyName]";

            return(report);
        }