using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace RaportMasterDetail
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'NorthwindDataSet.Employees' table. You can move, or remove it, as needed.
            this.EmployeesTableAdapter.Fill(this.NorthwindDataSet.Employees);
            // TODO: This line of code loads data into the 'NorthwindDataSet.Orders' table. You can move, or remove it, as needed.
            this.OrdersTableAdapter.Fill(this.NorthwindDataSet.Orders);

            this.reportViewer1.RefreshReport();
        }

        private void reportViewer1_Drillthrough(object sender, Microsoft.Reporting.WinForms.DrillthroughEventArgs e)
        {
            LocalReport lr = (LocalReport)e.Report;

            // DataSet1 to odpowiednia nazwa obiektu DataSet, którą użyto 
            // w trakcie konfiguracji źródła danych raportu Zamówienia
            ReportDataSource dataSource =
                new ReportDataSource("DataSet1", (DataTable)NorthwindDataSet.Orders);

            lr.DataSources.Clear();
            lr.DataSources.Add(dataSource);
            lr.Refresh();
        }
    }
}
