Esempio n. 1
0
        private void AddQuoteSection(ReportDocument reportDocument, ReportBuilder builder)
        {
            // add text sections
            builder.AddText("Underlying\n", TextStyle.Heading2);

            DataView view = new DataView(core.QuotesTable);

            view.RowFilter = "Stock = '" + core.StockSymbol + "'";

            // turn of all lines that aren't explicitly enabled later
            builder.DefaultTablePen = null;

            // default format
            string NX = "N" + Comm.Server.DisplayAccuracy.ToString();

            builder.AddTable(view, true);
            builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen;
            builder.Table.InnerPenRow          = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.OuterPenBottom       = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.HorizontalAlignment  = ReportPrinting.HorizontalAlignment.Left;

            // columns
            string[] field = new string[] { "Stock", "Name", "Last", "Change", "Open", "Volume", "DividendRate", "HistoricalVolatility", "ImpliedVolatility", "UpdateTimeStamp" };
            string[] title = new string[] { "Stock", "Name", "Last", "Change", "Open", "Volume", "Dividend Rate", "Historical Volatility", "Implied Volatility", "Time" };
            string[] formt = new string[] { "", "", NX, NX, NX, "N0", "P2", "N2", "N2", "dd-MMM-yy" };
            float[]  width = new float[] { 0.60f, 1.55f, 0.60f, 0.60f, 0.60f, 0.60f, 0.60f, 0.60f, 0.60f, 0.65f };
            HorizontalAlignment[] align = new HorizontalAlignment[] { HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center };

            for (int i = 0; i < field.Length; i++)
            {
                builder.AddColumn(field[i], title[i], width[i], false, false, align[i]);
                if (formt[i] != "")
                {
                    builder.CurrentColumn.FormatExpression = formt[i];
                }
                builder.CurrentColumn.HeaderTextStyle.StringAlignment = StringAlignment.Center;
            }
        }
Esempio n. 2
0
        private void AddStrategySection(ReportDocument reportDocument, ReportBuilder builder)
        {
            // add text sections
            builder.AddText("\n\nStrategy\n", TextStyle.Heading2);

            DataView view = new DataView(core.PositionsTable);

            view.RowFilter = "Enable = 'True'";

            // turn of all lines that aren't explicitly enabled later
            builder.DefaultTablePen = null;

            // default format
            string NX = "N" + Comm.Server.DisplayAccuracy.ToString();

            builder.AddTable(view, true);
            builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen;
            builder.Table.InnerPenRow          = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.OuterPenBottom       = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.HorizontalAlignment  = ReportPrinting.HorizontalAlignment.Left;

            // columns
            string[] field = new string[] { "Type", "Strike", "Expiration", "Symbol", "Quantity", "Price", "LastPrice", "Volatility", "Commission", "NetMargin", "MktValue", "Investment" };
            string[] title = new string[] { "Type", "Strike", "Expiration", "Symbol", "Quantity", "Price", "Last", "Volatility", "Comm.", "Margin", "Debit", "Investment" };
            string[] formt = new string[] { "", NX, "dd-MMM-yy", "", "N0", NX, NX, "N2", "N2", NX, NX, NX };
            float[]  width = new float[] { 0.50f, 0.50f, 0.65f, 0.55f, 0.55f, 0.55f, 0.55f, 0.60f, 0.60f, 0.60f, 0.60f, 0.70f };
            HorizontalAlignment[] align = new HorizontalAlignment[] { HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Center, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right };

            for (int i = 0; i < field.Length; i++)
            {
                builder.AddColumn(field[i], title[i], width[i], false, false, align[i]);
                if (formt[i] != "")
                {
                    builder.CurrentColumn.FormatExpression = formt[i];
                }
                builder.CurrentColumn.HeaderTextStyle.StringAlignment = StringAlignment.Center;
            }
        }
Esempio n. 3
0
        private void AddSummarySection(ReportDocument reportDocument, ReportBuilder builder)
        {
            // add text sections
            builder.AddText("\n\nSummary\n", TextStyle.Heading2);

            DataView view = new DataView(core.ResultsTable);

            // turn of all lines that aren't explicitly enabled later
            builder.DefaultTablePen = null;

            // default format
            string NX = "N" + Comm.Server.DisplayAccuracy.ToString();

            builder.AddTable(view, true);
            builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen;
            builder.Table.InnerPenRow          = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.OuterPenBottom       = new Pen(Color.Gray, reportDocument.ThinPen.Width);
            builder.Table.HorizontalAlignment  = ReportPrinting.HorizontalAlignment.Left;

            // columns
            string[] field = new string[] { "Criteria", "Price", "Change", "Prob", "Total", "TotalPrc", "MonthlyPrc" };
            string[] title = new string[] { "Criteria", "Price", "Change", "Probability", "Total Return", "Total Return%", "Monthly Return %" };
            string[] formt = new string[] { "", NX, NX, "N2", "N2", "P2", "P2" };
            float[]  width = new float[] { 2.45f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f };
            HorizontalAlignment[] align = new HorizontalAlignment[] { HorizontalAlignment.Left, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right, HorizontalAlignment.Right };

            for (int i = 0; i < field.Length; i++)
            {
                builder.AddColumn(field[i], title[i], width[i], false, false, align[i]);
                if (formt[i] != "")
                {
                    builder.CurrentColumn.FormatExpression = formt[i];
                }
                builder.CurrentColumn.HeaderTextStyle.StringAlignment = StringAlignment.Center;
            }
        }
Esempio n. 4
0
 public void MakeDocument(ReportDocument reportDocument)
 {
     if (this.mObj != null)
     {
         TextStyle.ResetStyles();
         DateTime serverDtm = GlobalWebServiceDAL.GetServerDtm();
         float    num       = 1f;
         float    num2      = 10f;
         float    num3      = 10f;
         float    num4      = 420f;
         float    num5      = 480f;
         float    num6      = 150f;
         float    num7      = 100f;
         try
         {
             num = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.pen.width"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num2 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.box.margin"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num3 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.box.padding"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num4 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.box.width"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num5 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.box.height"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num6 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.col1.width"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num7 = Convert.ToSingle(ConfigurationSettings.AppSettings["eiroutprint.col2.width"]);
         }
         catch (Exception)
         {
         }
         Pen           borders = new Pen(Color.White, num / 100f);
         Pen           pen     = new Pen(Color.Black, num / 100f);
         ReportBuilder builder = new ReportBuilder(reportDocument);
         builder.StartBox(num2 / 100f, borders, num3 / 100f, Brushes.White, num4 / 100f, num5 / 100f);
         builder.StartLinearLayout(Direction.Vertical);
         builder.DefaultTablePen = borders;
         string name       = "Times New Roman";
         int    num8       = 12;
         string text       = "PT. MULTICON INDRAJAYA TERMINAL";
         string str3       = "EQUIPMENT INTERCHANGE RECEIPT (OUT)";
         string str4       = "Lucida Console";
         int    num9       = 10;
         string headerText = "D/O No.";
         string str6       = "Shipper";
         string str7       = "VESSEL/VOY No.";
         string str8       = "Destination";
         string str9       = "Quantity";
         string str10      = "Principal";
         string str11      = "Delivered";
         string str12      = "Vehicle No.";
         string str13      = "Lucida Console";
         int    num10      = 10;
         string str14      = "CONTAINER PREFIX + NUMBER";
         string str15      = "SIZE";
         string str16      = "TYPE";
         string str17      = "CONDITION";
         string str18      = "SEAL NUMBER";
         string format     = "REMARKS : {0} {1} {2}";
         string str20      = "Arial";
         int    num11      = 10;
         string str21      = "Printed and Authorized, {0} {1}";
         string str22      = "PT. MULTICON INDRAJAYA TERMINAL";
         try
         {
             num8 = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.header.font.size"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num9 = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.main.font.size"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num10 = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.line.font.size"]);
         }
         catch (Exception)
         {
         }
         try
         {
             num11 = Convert.ToInt32(ConfigurationSettings.AppSettings["eiroutprint.footer.font.size"]);
         }
         catch (Exception)
         {
         }
         try
         {
             name = ConfigurationSettings.AppSettings["eiroutprint.header.font.name"];
         }
         catch (Exception)
         {
         }
         try
         {
             text = ConfigurationSettings.AppSettings["eiroutprint.header.1"];
         }
         catch (Exception)
         {
         }
         try
         {
             str3 = ConfigurationSettings.AppSettings["eiroutprint.header.2"];
         }
         catch (Exception)
         {
         }
         try
         {
             str4 = ConfigurationSettings.AppSettings["eiroutprint.main.font.name"];
         }
         catch (Exception)
         {
         }
         try
         {
             headerText = ConfigurationSettings.AppSettings["eiroutprint.main.1"];
         }
         catch (Exception)
         {
         }
         try
         {
             str6 = ConfigurationSettings.AppSettings["eiroutprint.main.2"];
         }
         catch (Exception)
         {
         }
         try
         {
             str7 = ConfigurationSettings.AppSettings["eiroutprint.main.3"];
         }
         catch (Exception)
         {
         }
         try
         {
             str8 = ConfigurationSettings.AppSettings["eiroutprint.main.4"];
         }
         catch (Exception)
         {
         }
         try
         {
             str9 = ConfigurationSettings.AppSettings["eiroutprint.main.5"];
         }
         catch (Exception)
         {
         }
         try
         {
             str10 = ConfigurationSettings.AppSettings["eiroutprint.main.6"];
         }
         catch (Exception)
         {
         }
         try
         {
             str11 = ConfigurationSettings.AppSettings["eiroutprint.main.7"];
         }
         catch (Exception)
         {
         }
         try
         {
             str12 = ConfigurationSettings.AppSettings["eiroutprint.main.8"];
         }
         catch (Exception)
         {
         }
         try
         {
             str13 = ConfigurationSettings.AppSettings["eiroutprint.line.font.name"];
         }
         catch (Exception)
         {
         }
         try
         {
             str14 = ConfigurationSettings.AppSettings["eiroutprint.line.1"];
         }
         catch (Exception)
         {
         }
         try
         {
             str15 = ConfigurationSettings.AppSettings["eiroutprint.line.2"];
         }
         catch (Exception)
         {
         }
         try
         {
             str16 = ConfigurationSettings.AppSettings["eiroutprint.line.3"];
         }
         catch (Exception)
         {
         }
         try
         {
             str17 = ConfigurationSettings.AppSettings["eiroutprint.line.4"];
         }
         catch (Exception)
         {
         }
         try
         {
             str18 = ConfigurationSettings.AppSettings["eiroutprint.line.5"];
         }
         catch (Exception)
         {
         }
         try
         {
             format = ConfigurationSettings.AppSettings["eiroutprint.line.6"];
         }
         catch (Exception)
         {
         }
         try
         {
             str20 = ConfigurationSettings.AppSettings["eiroutprint.footer.font.name"];
         }
         catch (Exception)
         {
         }
         try
         {
             str21 = ConfigurationSettings.AppSettings["eiroutprint.footer.1"];
         }
         catch (Exception)
         {
         }
         try
         {
             str22 = ConfigurationSettings.AppSettings["eiroutprint.footer.2"];
         }
         catch (Exception)
         {
         }
         TextStyle textStyle = new TextStyle(TextStyle.BoldStyle);
         textStyle.FontFamily      = new FontFamily(name);
         textStyle.Size            = num8;
         textStyle.StringAlignment = StringAlignment.Center;
         TextStyle style2 = new TextStyle(TextStyle.Normal);
         style2.FontFamily = new FontFamily(str4);
         style2.Size       = num9;
         TextStyle style3 = new TextStyle(TextStyle.Normal);
         style3.FontFamily = new FontFamily(str13);
         style3.Size       = num10;
         TextStyle style4 = new TextStyle(TextStyle.Normal);
         style4.FontFamily = new FontFamily(str20);
         style4.Size       = num11;
         builder.AddText(text, textStyle);
         builder.AddText(str3, textStyle);
         builder.AddHorizontalLine(pen);
         DataTable table = new DataTable("main");
         table.Columns.Add("column1", typeof(string));
         table.Columns.Add("column2", typeof(string));
         table.Rows.Add(new object[] { str6, this.mObj.Shipper });
         table.Rows.Add(new object[] { str7, this.mObj.VesselVoyageName });
         table.Rows.Add(new object[] { str8, this.mObj.DestinationName });
         table.Rows.Add(new object[] { str9, "?" });
         table.Rows.Add(new object[] { str10, this.mCust.Name });
         table.Rows.Add(new object[] { str11, this.mObj.AngkutanOut });
         table.Rows.Add(new object[] { str12, this.mObj.NoMobilOut });
         SectionTable table2 = builder.AddTable(table.DefaultView, true);
         table2.InnerPenHeaderBottom.Color = Color.White;
         table2.InnerPenRow.Color          = Color.White;
         table2.HeaderTextStyle.SetFromFont(style2.GetFont());
         table2.HorizontalAlignment = HorizontalAlignment.Center;
         ReportDataColumn column = builder.AddColumn("column1", headerText, num6 / 100f, false, false);
         column.HeaderTextStyle         = style2;
         column.DetailRowTextStyle      = style2;
         column.AlternatingRowTextStyle = style2;
         ReportDataColumn column2 = builder.AddColumn("column2", this.mObj.DoNumber, num7 / 100f, false, false);
         column2.HeaderTextStyle         = style2;
         column2.DetailRowTextStyle      = style2;
         column2.AlternatingRowTextStyle = style2;
         builder.AddHorizontalLine(pen);
         DataTable table3 = new DataTable("line");
         table3.Columns.Add("column1", typeof(string));
         table3.Columns.Add("column2", typeof(string));
         table3.Rows.Add(new object[] { str15, this.mObj.Size });
         table3.Rows.Add(new object[] { str16, this.mObj.Type });
         table3.Rows.Add(new object[] { str17, this.mObj.Condition });
         table3.Rows.Add(new object[] { str18, this.mObj.Seal });
         SectionTable table4 = builder.AddTable(table3.DefaultView, true);
         table4.InnerPenHeaderBottom = borders;
         table4.InnerPenRow          = borders;
         table4.OuterPens            = borders;
         table4.HeaderTextStyle.SetFromFont(style3.GetFont());
         table4.HorizontalAlignment = HorizontalAlignment.Center;
         ReportDataColumn column3 = builder.AddColumn("column1", str14.Replace('+', '&'), num6 / 100f, false, false);
         column3.HeaderTextStyle         = style3;
         column3.DetailRowTextStyle      = style3;
         column3.AlternatingRowTextStyle = style3;
         ReportDataColumn column4 = builder.AddColumn("column2", this.mObj.Cont, num7 / 100f, false, false);
         column4.HeaderTextStyle         = style3;
         column4.DetailRowTextStyle      = style3;
         column4.AlternatingRowTextStyle = style3;
         builder.AddText(" ", style3);
         builder.AddText(string.Format(format, this.mObj.Remarks), style3);
         builder.AddHorizontalLine(pen);
         builder.AddText(" ", style4);
         string introduced93 = serverDtm.ToLongDateString();
         builder.AddText(string.Format(str21, introduced93, serverDtm.ToLongTimeString()), style4);
         builder.AddText(str22, style4);
         builder.AddText(" \r\n ", style4);
         builder.FinishLinearLayout();
         builder.FinishBox();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// This prints out the contents of a datagrid using  ReportBuilder
        /// </summary>
        /// <param name="reportDocument"></param>
        public void MakeDocument(ReportDocument reportDocument)
        {
            if (dataGrid == null)
            {
                return;
            }

            // We may need a DataSet and Data Table depending on DataGrid source type
            DataTable       dataTable       = new DataTable();
            DataSet         dataSet         = new DataSet();
            DataViewManager dataViewManager = new DataViewManager();
            DataView        dataView        = new DataView();

            // We may need to create a DataView depending on the type of DataSouce that is
            // in the DataGrid
            bool dataViewExpected = true;

            //Depending on the Source and if there is a valid data memember we may need
            //to create a dataView, We actually will try and get the dataView later on
            //from the currency manager as this will let us show the datatable if we
            //have drilled down.
            switch (dataGrid.DataSource.GetType().ToString())
            {
            case "System.Data.DataViewManager":
            {
                #region
                //Check that a view is being shown, if no load views into a table
                if (dataGrid.DataMember == String.Empty)
                {
                    dataViewExpected = false;
                    //ok no Data View is active so print out he DataView
                    dataTable = new DataTable("DataViewManager");
                    DataColumn dataColumn
                        = dataTable.Columns.Add("TableID", typeof(String));
                    //Get the dataViewManger from the DataGrid source
                    dataViewManager = (DataViewManager)dataGrid.DataSource;
                    //Add a dataRow to our little table for each DataView Setting
                    foreach (DataViewSetting dvs in dataViewManager.DataViewSettings)
                    {
                        dataTable.Rows.Add(new string[] { dvs.Table.TableName });
                    }
                    //Now Create a DataView that the ReportPRinting can use to print
                    dataView = new DataView(dataTable);
                }
                #endregion
                break;
            }

            case "System.Data.DataView":
            {
                dataView = (DataView)dataGrid.DataSource;
                break;
            }

            case "System.Data.DataTable":
            {
                dataView = ((DataTable)dataGrid.DataSource).DefaultView;
                break;
            }

            case "System.Data.DataSet":
            {
                #region
                //If DataGrid uses a Data set than the DataTable is in DataMember
                if (dataGrid.DataMember == String.Empty)
                {
                    dataViewExpected = false;

                    //ok no Data View is active so print out tables in DataSet
                    //by first creating a dataTable and loading the dataSet Table names
                    //into it so we can create a dataView
                    dataTable = new DataTable("DataSetTables");
                    DataColumn dataColumn
                        = dataTable.Columns.Add("TableID", typeof(String));
                    //Get the DataSet from the DataGrid source
                    dataSet = (DataSet)dataGrid.DataSource;
                    //Load the name of each table in the dataSet into our new table
                    foreach (DataTable dt in dataSet.Tables)
                    {
                        dataTable.Rows.Add(new string[] { dt.TableName });
                    }
                    //Now Create a DataView that the ReportPRinting can use to print
                    dataView = new DataView(dataTable);
                }
                #endregion
                break;
            }
            }
            // See if we can pickup the current view from the currency manager
            // This should also pickup if we are drilled down on any relations etc
            // This will be skipped where there was no dataView obtainable from the
            // dataGrid dataSource and DataMember
            CurrencyManager currencyManager;
            if (dataViewExpected)
            {
                //Currency Manager for the DataGrid
                //if (dataGrid.BindingContext
                //    [dataGrid.DataSource, dataGrid.DataMember] != null)
                //{
                currencyManager
                    = (CurrencyManager)dataGrid.BindingContext
                      [dataGrid.DataSource, dataGrid.DataMember];

                //This is the DataView that we are going to fill up...
                dataView = (DataView)currencyManager.List;
                //}
            }
            // Setup the document's settings
            reportDocument.DefaultPageSettings = pageSettings;

            reportBuilder.StartLinearLayout(Direction.Vertical);
            // Print out the actual Report Page
            #region page header/footer (replaced)

            /*
             *
             * %p is code for the page number
             * string pageStr = "-%p-";
             *
             * string tableName=dataView.Table.TableName;
             *
             * reportBuilder.AddPageHeader(
             *      // First page
             *      pageStr, tableName  , String.Empty,
             *      // Right pages
             *      pageStr,	tableName , String.Empty,
             *      // Odd pages
             *      String.Empty, tableName, pageStr);
             *
             * reportBuilder.AddPageFooter (DateTime.Now.ToLongDateString(), ReportPrinting.HorizontalAlignment.Center);
             */
            #endregion
            //Now lets print out the Datagrid - First the Heading
            reportBuilder.AddText(dataGrid.CaptionText, TextStyle.BoldStyle);
            #region parent relations (not needed)
            // We need to print any parent row info here
            // Check the dataGrid.DataMember and see if it is a data relation
            // If it is then get the first DataRow in the DataGrid and then
            // use its GetParentRows method, Each row should be checked to see
            // if there was a DataGridTableStyle set up for it
            // We have to work our way backwards up the data relation building strings that
            // need to be printed in reverse order to match the way the dataGrid displays
            if (dataGrid.ParentRowsVisible &&                           //Are parents rows showing??
                dataViewExpected &&                                     //If no view then skip this
                dataGrid.DataMember.LastIndexOf(".") > 0)               //check Tablename.Relation
            {
                DataRowView dataRowView1 = dataView[0];                 //first get the DataRow View
                DataRow     dataRow1     = dataRowView1.Row;            //Now get the DataRow for viewRow

                //break up the DataRelations string into its parts
                //[0] will be the original table,[1][..] will be relations
                //This need to be processed from last to first as the last one is
                //what is currently being displayed on the data grid
                string [] relations = dataGrid.DataMember.Split(new Char [] { '.' });

                //we will build an array of strings of parent data showing on the
                //datagrid that needs to be printed in reverse order
                //of the way they were built on the DataGrid in order
                //to replicate the drill down on the data grid.
                string[] parentText = new string[relations.Length - 1];

                //Go through each Relation from the last to first and get the parent rows
                //of the childRow using the data relations for that parent-child relation
                for (int r = relations.Length - 1; r > 0; r--)
                {
                    //If a child has multiple parent rows than we need to figure out which
                    //is parent for this drill down. To get the information for each
                    //parent row we are going to build a string with table & relations
                    //which is the same as the dataGrid Builds automatically on drilldown
                    //for the DataMember field which we will store in parentMember.
                    //parentMember will then be used to get the correct currencyManager
                    //which in turn will get the correct dataview,dataRowView and DataRow
                    //IE TABLENAME.RELATION1.RELATION2 etc
                    string parentMember = String.Empty;
                    for (int i = 0; i < r; i++)
                    {
                        parentMember += relations[i];
                        if (i < r - 1)
                        {
                            parentMember += ".";                             //Separate with periods except last
                        }
                    }
                    //Now that we have the parentMember we need to get the currency
                    //manager for that parentmember which is holding the current
                    //DataView from which we will get the
                    currencyManager
                        = (CurrencyManager)dataGrid.BindingContext
                          [dataGrid.DataSource, parentMember];

                    //This is the DataView that we are going to fill up...
                    DataView    parentDataView = (DataView)currencyManager.List;
                    DataRowView parentDataRowView
                        = (DataRowView)currencyManager.Current;                          //first get the DataRow View

                    DataRow parentRow = parentDataRowView.Row;

                    //Start with the TableName:
                    parentText[r - 1] = parentRow.Table.TableName + ":  ";

                    //	Determine if there is DataGrid Table Style for the parent table
                    // or do we just go through all the columns in the parent DataTable
                    try
                    {
                        DataGridTableStyle tableStyle
                            = dataGrid.TableStyles[parentRow.Table.TableName];
                        //Go through the table style columns & build the parent text line
                        foreach (DataGridColumnStyle columnStyle
                                 in tableStyle.GridColumnStyles)
                        {
                            parentText[r - 1] += columnStyle.MappingName + ": "
                                                 + parentRow[columnStyle.MappingName].ToString() + "   ";
                        }
                    }
                    catch
                    {
                        //Go through the columns in the parentRow DataTable and built
                        //the parent text line
                        foreach (DataColumn dataColumn
                                 in parentRow.Table.Columns)
                        {
                            parentText[r - 1] += dataColumn.ColumnName + ": "
                                                 + parentRow[dataColumn].ToString() + "   ";
                        }
                    }
                }
                //Now print out all the Parent Text array using the report builder

                for (int i = 0; i < parentText.Length; i++)
                {
                    reportBuilder.AddHorizontalLine();
                    reportBuilder.AddText(parentText[i], TextStyle.Normal);
                }
                reportBuilder.AddHorizontalLine();
            }
            #endregion
            // Add dataView & all columns that are in the data grid
            reportBuilder.AddTable(dataView, true);
            // Now we have to determine if there was a DataGridTableStyle setup for this
            // DataGrid, The default will be to load from the DataView table columns
            bool loadFromDataView = true;
            //If there is a DataGridTableStyle - Add any columns showing in the grid..
            foreach (DataGridTableStyle tableStyle in dataGrid.TableStyles)
            {
                //reportBuilder.AddTable(dataView, true);//dzs
                GraphicsUnit unit   = reportDocument.DocumentUnit;                      //dzs
                Rectangle    bounds = pageSettings.Bounds;                              //dzs
                System.Drawing.Printing.Margins margins = pageSettings.Margins;         //dzs
                float availSpace = (bounds.Width - margins.Right - margins.Left) / 100; //dzs - should = 10 for landscape on 8.5x11 sheet
                float usedSpace  = 0;                                                   //Keep running total
                if (tableStyle.MappingName == dataView.Table.TableName)
                {
                    loadFromDataView = false;
                    foreach (DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles)
                    {
                        float maxWidth = (float)columnStyle.Width / 80; //Not sure if correct sizing
                        usedSpace += maxWidth;
                        if (usedSpace > availSpace)                     //this column will run off the page
                        {
                            usedSpace = 0;                              //Reset the space used
                            reportBuilder.AddPageBreak();               //dzs
                            //reportBuilder.FinishLinearLayout();//dzs
                            //reportBuilder.StartLinearLayout(Direction.Vertical);
                            reportBuilder.AddTable(dataView, true);
                        }
                        reportBuilder.AddColumn(columnStyle.MappingName, columnStyle.HeaderText,
                                                maxWidth,
                                                false, false,       //dzs - do not autosize columns
                                                (ReportPrinting.HorizontalAlignment)columnStyle.Alignment);

                        DataGridTextBoxColumn textCol = columnStyle as DataGridTextBoxColumn;
                        if (textCol != null)
                        {
                            //Debug.WriteLine (textCol.Format);
                            reportBuilder.CurrentColumn.FormatExpression = textCol.Format;
                        }
                        //float colWidth = reportBuilder.CurrentColumn.Width;//dzs
                        //ReportDataColumn repColumn = reportBuilder.CurrentColumn;//dzs
                    }
                }
            }
            //If this is still true than we have to load from the Table columns in the
            //dataView that the datagrid is using.
            //
            // IE there was NOT a valid DataGridTableStyle in the datagrid
            if (loadFromDataView)
            {
                reportBuilder.AddAllColumns(maxColumnSize, true, true);
            }
            reportBuilder.FinishLinearLayout();
        }