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


namespace Baza_Reklam
{
    public partial class DaneKlientaViewer : Form
    {
        public DaneKlientaViewer(int custId)
        {
            InitializeComponent();

            KLIENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
            kliencI_OSOBY_DO_KONTAKTUTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;

            KLIENCITableAdapter.FillByCustomerId(REKLAMADataSet.KLIENCI, custId);
            kliencI_OSOBY_DO_KONTAKTUTableAdapter1.FillByCustomerId(REKLAMADataSet.KLIENCI_OSOBY_DO_KONTAKTU, custId);

            reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessing);
        }

        public DaneKlientaViewer(List<int> custId)
        {
            InitializeComponent();

            KLIENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
            kliencI_OSOBY_DO_KONTAKTUTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;

            KLIENCITableAdapter.ClearBeforeFill = false;
            kliencI_OSOBY_DO_KONTAKTUTableAdapter1.ClearBeforeFill = false;

            foreach (int i in custId)
            {
                KLIENCITableAdapter.FillByCustomerId(REKLAMADataSet.KLIENCI, i);
                kliencI_OSOBY_DO_KONTAKTUTableAdapter1.FillByCustomerId(REKLAMADataSet.KLIENCI_OSOBY_DO_KONTAKTU, i);
            }

            reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessing);
        }

        private void DaneKlientaViewer_Load(object sender, EventArgs e)
        {
            this.reportViewer1.RefreshReport();
        }

        void SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        {
            e.DataSources.Add(new ReportDataSource("REKLAMADataSet_KLIENCI_OSOBY_DO_KONTAKTU", this.REKLAMADataSet.KLIENCI_OSOBY_DO_KONTAKTU));
        }
    }
}