using System;
using System.Diagnostics;
using System.Windows.Forms;
using SepehrHotelApiSampleClient.Booking.Book.WinForms;
using SepehrHotelApiSampleClient.Generic.WinForms;
using SearchByCityAndDateAndGuests = SepehrHotelApiSampleClient.Availability.SearchByCityAndDateAndGuests.WinForms;
using SearchByCityAndDate = SepehrHotelApiSampleClient.Availability.SearchByCityAndDate.WinForms;
using GetByDateRange = SepehrHotelApiSampleClient.Availability.GetCheckinAndCheckoutCompositions.WinForms;
using GetByFromDateAndToDateForm = SepehrHotelApiSampleClient.Availability.GetByFromDateAndToDate.WinForms;

namespace SepehrHotelApiSampleClient
{
    public partial class MainForm : Form
    {
        private readonly SearchByCityAndDateAndGuests.SearchByCityAndDateAndGuestsForm _searchByCityAndDateAndGuestsForm;
        private readonly SearchByCityAndDate.SearchByCityAndDateForm _searchByCityAndDateForm;
        private readonly GetByDateRange.GetCheckinAndCheckoutCompositionsForm _getCheckinAndCheckoutCompositionsForm;
        private readonly GetByFromDateAndToDateForm.GetByFromDateAndToDateForm _getByFromDateAndToDateForm;
        private readonly BookedPnrForm _bookedPnrForm;
        private readonly FailedRequestsForm _failedRequestsForm;

        public MainForm()
        {
            InitializeComponent();

            _searchByCityAndDateAndGuestsForm = new SearchByCityAndDateAndGuests.SearchByCityAndDateAndGuestsForm(this);
            _searchByCityAndDateAndGuestsForm.TopLevel = false;
            _searchByCityAndDateAndGuestsForm.Parent = tbgSearchByCityAndDateAndGuests;
            _searchByCityAndDateAndGuestsForm.Show();

            _searchByCityAndDateForm = new SearchByCityAndDate.SearchByCityAndDateForm(this);
            _searchByCityAndDateForm.TopLevel = false;
            _searchByCityAndDateForm.Parent = tbgSearchByCityAndDate;
            _searchByCityAndDateForm.Show();


            _getCheckinAndCheckoutCompositionsForm = new GetByDateRange.GetCheckinAndCheckoutCompositionsForm(this);
            _getCheckinAndCheckoutCompositionsForm.TopLevel = false;
            _getCheckinAndCheckoutCompositionsForm.Parent = tbgCheckinAndCheckoutCompositions;
            _getCheckinAndCheckoutCompositionsForm.Show();

            _getByFromDateAndToDateForm = new GetByFromDateAndToDateForm.GetByFromDateAndToDateForm(this);
            _getByFromDateAndToDateForm.TopLevel = false;
            _getByFromDateAndToDateForm.Parent = tbgGetByFromDateAndToDate;
            _getByFromDateAndToDateForm.Show();


            _bookedPnrForm = new BookedPnrForm(this);
            _bookedPnrForm.TopLevel = false;
            _bookedPnrForm.Parent = tbgBookedPnrs;
            _bookedPnrForm.Show();

            _failedRequestsForm = new FailedRequestsForm(this);
            _failedRequestsForm.TopLevel = false;
            _failedRequestsForm.Parent = tbgFailedRequests;
            _failedRequestsForm.Show();

            var currentBalanceForm = new CurrentBalanceForm(this);
            currentBalanceForm.TopLevel = false;
            currentBalanceForm.Parent = tbgCurrentBalance;
            currentBalanceForm.Show();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            //Put your username for easier debugging here
            if (Debugger.IsAttached)
            {
                txtUrl.Text = "https://192.168.1.123";
                txtUsername.Text = "TestDev1";
                txtPassword.Text = "25f9e794323b453885f5181f1b624d0b";
            }
        }

        private void tbgBookedPnrs_Enter(object sender, EventArgs e)
        {
            _bookedPnrForm.DataBindGrid();
        }

        private void tbgRefundPendingRequests_Enter(object sender, EventArgs e)
        {
            
        }

        private void tbgHistory_Enter(object sender, EventArgs e)
        {
            _bookedPnrForm.DataBindGrid();
        }
    }
}
