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;

namespace hukpiWinApp.Forms
{
    public partial class ReportDetailsRouteForm : BaseForm
    {
        public ReportDetailsRouteForm()
        {
            InitializeComponent();
        }

        private void buttonOpenReport_Click(object sender, EventArgs e)
        {
            bool isWinterSelected = radioFieldDefaultSeason1.isWinterSelected();
            List<decimal> routeCodesList = null;
            List<decimal> modalitiesList = null;
            List<decimal> transportDaysList = null;

            if (radioFieldAllVsNothingRoutes.RadioButtonSelectedChecked)
            {
                routeCodesList = Utils.getChoosenIdsFromListView(listViewRouteCodes);
            }

            if (radioFieldAllVsNothingModalities.RadioButtonSelectedChecked)
            {
                modalitiesList = Utils.getChoosenIdsFromListView(listViewModalities);
            }

            if (radioFieldAllVsNothingTransportDays.RadioButtonSelectedChecked)
            {
                transportDaysList = Utils.getTransportDaysIdBasedOnDays(checkBoxFieldDays.getCheckedDaysList(), isWinterSelected);
            }

            ReportViewerRoutesForm reportViewer = new ReportViewerRoutesForm(isWinterSelected, routeCodesList, modalitiesList, transportDaysList);
            if (((MainForm)this.MdiParent).openNewMDIChildForm(reportViewer))
            {
                reportViewer.button1_Click(null, null);
            }
        }

        private void showEditRoutes()
        {
            BaseEditListViewWithTwoPanelForm editRoutes = new BaseEditListViewWithTwoPanelForm(Utils.getRoutesForListView(), listViewRouteCodes);
            editRoutes.Text = "Járatkód választó";
            editRoutes.ShowDialog();
            this.Focus();
        }

        private void listViewRouteCodes_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            showEditRoutes();
        }

        private void listViewRouteCodes_Click(object sender, EventArgs e)
        {
            showEditRoutes();
        }

        private void showEditModalities()
        {
            BaseEditListViewWithTwoPanelForm editModalities = new BaseEditListViewWithTwoPanelForm(Utils.getModalitiesForListView(), listViewModalities);
            editModalities.Text = "Jelleg választó";
            editModalities.ShowDialog();
            this.Focus();
        }

        private void listViewModalities_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            showEditModalities();
        }

        private void listViewModalities_Click(object sender, EventArgs e)
        {
            showEditModalities();
        }
    }
}
