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 hukpiWinApp.Forms
{
    public partial class ReportViewerRoutesForm : BaseForm
    {
        bool inWinter;
        List<decimal> routeCodesList = null;
        List<decimal> modalitiesList = null;
        List<decimal> transportDaysList = null;

        public ReportViewerRoutesForm(bool inWinter, List<decimal> routeCodesList, List<decimal> modalitiesList, List<decimal> transportDaysList)
        {
            InitializeComponent();
            this.inWinter = inWinter;
            this.routeCodesList = routeCodesList;
            this.modalitiesList = modalitiesList;
            this.transportDaysList = transportDaysList;
            
            // TODO: This line of code loads data into the 'hukpiDatabaseDataSet.DataTable1' table. You can move, or remove it, as needed.
            //this.dataTable1TableAdapter.Fill(this.hukpiDatabaseDataSet.DataTable1, 2);
            
        }

        private void ReportViewerForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'hukpiDatabaseDataSet.ReportRoutesSimpleView' table. You can move, or remove it, as needed.
            //this.reportRoutesSimpleViewTableAdapter.FillWithWinterDays(this.hukpiDatabaseDataSet.ReportRoutesSimpleView);

            string ReportCaption = "Jelentés a járatokról";

            string season = "";


            string routeCodes = "";
            if (this.routeCodesList != null)
            {
                routeCodes = " ( " + Utils.implode(", ", Utils.getRouteCodesByIdList(this.routeCodesList)) + " ) ";
                ReportCaption += routeCodes;
            }

            if (this.inWinter)
            {
                season = ", 'Téli' időszak ";
            }
            else
            {
                season = ", 'Nyári' időszak ";
            }
            ReportCaption += season;

            string modalities = "";
            if (this.modalitiesList != null)
            {
                modalities = " (Jellegek: " + Utils.implode(", ", Utils.getModalityCodesByIdList(this.modalitiesList)) + " ) ";
                ReportCaption += modalities;
            }

            
            ReportParameter p = new ReportParameter("Title", ReportCaption);
            
            this.reportRoutesSimpleViewTableAdapter.FillByRoutesModalitiesAndTransportDays(this.hukpiDatabaseDataSet.ReportRoutesSimpleView, this.inWinter, this.routeCodesList, this.modalitiesList, this.transportDaysList);
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {p});
            //this.reportViewer1.RefreshReport();
        }

        

        public void button1_Click(object sender, EventArgs e)
        {
            this.reportViewer1.RefreshReport();
            this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            
        }
    }
}
