Exemplo n.º 1
0
        /// <summary>
        /// btnCustomersLeveled_Click - Creates a OrdersLeveled report and sets
        /// the data source for it.
        /// </summary>
        private void btnCustomersLeveled_Click(object sender, EventArgs e)
        {
            try
            {
                //OrdersLeveled rpt = new OrdersLeveled();
                var rpt = new SectionReport();
                rpt.LoadLayout(XmlReader.Create(Properties.Resources.OrdersLeveled));

                Data.XMLDataSource ds = rpt.DataSource as Data.XMLDataSource;
                if (ds == null)
                {
                    // Display the message when an error occurs.
                    MessageBox.Show(Properties.Resources.DataSourceError, this.Text);
                    return;
                }

                // Set the XML file name.
                ds.FileURL = Properties.Resources.ConnectionString;

                // Display the report.
                ViewerForm frm = new ViewerForm();
                frm.Show();
                frm.LoadReport(rpt);
            }
            catch (ReportException ex)
            {
                MessageBox.Show(ex.ToString(), Text);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Illustrates using a GrapeCity XML object as a data source.
 ///
 /// </summary>
 private void btnXML_Click(object sender, EventArgs e)
 {
     //Initialize the Open Dialog Box
     dlgOpen.Title    = "Open Data File...";
     dlgOpen.FileName = dlgSave.FileName;
     dlgOpen.Filter   = "XML Data (*.xml)|*.xml";
     if (dlgOpen.ShowDialog() == DialogResult.OK)
     {
         //If valid name is returned, open the data and run the report
         if (dlgOpen.FileName.Length != 0)
         {
             Cursor = Cursors.WaitCursor;
             //XML Data Source object to use
             Data.XMLDataSource xml = new Data.XMLDataSource();
             //Assign the FileName for the selected XML data file
             xml.FileURL = dlgOpen.FileName;
             //Assign the Recordset Pattern
             xml.RecordsetPattern = @"//Northwind/Invoices";
             //Create the report and assign the data source
             Invoice rpt = new Invoice();
             rpt.DataSource = xml;
             //Run and view the report
             arvMain.LoadDocument(rpt);
             Cursor = Cursors.Arrow;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// btnCustomers_Click - Checks the radio options and sets the report object's data
        /// </summary>
        private void btnCustomers_Click(object sender, EventArgs e)
        {
            try
            {
                var rpt = new SectionReport();
                rpt.LoadLayout(XmlReader.Create(Properties.Resources.CustomersOrders));

                Data.XMLDataSource ds = rpt.DataSource as Data.XMLDataSource;
                if (ds == null)
                {
                    // Display the message when an error occurs.
                    MessageBox.Show(Properties.Resources.DataSourceError, this.Text);
                    return;
                }

                ds.FileURL = Properties.Resources.ConnectionString;

                // Set an XSL pattern to get the node (record) based on the report.
                if (radioAll.Checked)
                {
                    // Show all data
                    ds.RecordsetPattern = "//CUSTOMER";
                }
                else if (radioID.Checked)
                {
                    // Show data where ID = 2301
                    ds.RecordsetPattern = "//CUSTOMER[@id = " + @"""" + "2301" + @"""" + "]";
                }
                else if (radioEmail.Checked)
                {
                    // Show data where Email is valid
                    ds.RecordsetPattern = "//CUSTOMER[@email]";
                }

                ViewerForm frm = new ViewerForm();
                frm.Show();
                frm.LoadReport(rpt);
            }
            catch (ReportException ex)
            {
                MessageBox.Show(ex.ToString(), Text);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Format Event
 /// ActiveReports event that is called for every section (Page Header/Footer,
 /// but before the section is rendered to a page.The Format event is the only event in which you can change
 ///  the section's height. Use this section to set or change the properties of any controls or the section itself.
 /// Also use the Format event to pass information, such as an SQL String, to a Subreport.
 /// </summary>
 private void Detail_Format(object sender, System.EventArgs eArgs)
 {
     // Get a count of the item nodes from the datasource
     Data.XMLDataSource xmlDS = DataSource as Data.XMLDataSource;
     if (xmlDS == null)
     {
         lblItems.Text = "0";
         return;
     }
     // Get the item node list.
     System.Xml.XmlNodeList nodeList = xmlDS.Field("ITEM", true) as System.Xml.XmlNodeList;
     if (nodeList == null)
     {
         lblItems.Text = "0";
         return;
     }
     //Set the lblItems.Text to the count of Item nodes.
     lblItems.Text = string.Format(System.Globalization.CultureInfo.CurrentCulture, "Item Count: {0}", nodeList.Count);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Illustrates using a GrapeCity XML object as a data source.
        ///
        /// </summary>
        private void btnXML_Click(object sender, EventArgs e)
        {
            //Initialize the Open Dialog Box
            //

            dlgOpen.Title    = Properties.Resources.OpenDataFile;
            dlgOpen.FileName = dlgSave.FileName;
            dlgOpen.Filter   = Properties.Resources.Filter;

            if (dlgOpen.ShowDialog() == DialogResult.OK)
            {
                //If valid name is returned, open the data and run the report
                //
                if (dlgOpen.FileName.Length != 0)
                {
                    Cursor = Cursors.WaitCursor;

                    //XML Data Source object to use
                    Data.XMLDataSource xml = new Data.XMLDataSource();

                    //Assign the FileName for the selected XML data file
                    xml.FileURL = dlgOpen.FileName;
                    //Assign the Recordset Pattern
                    xml.RecordsetPattern = @"//Northwind/Invoices";

                    //Create the report and assign the data source
                    var rpt = new ActiveReports.SectionReport();
                    rpt.LoadLayout(XmlReader.Create(System.IO.Path.Combine("..\\..\\", Properties.Resources.ReportName)));
                    rpt.DataSource = xml;
                    //Run and view the report
                    arvMain.LoadDocument(rpt);

                    Cursor = Cursors.Arrow;
                }
            }
        }