using System;
using System.Diagnostics;
using System.Windows.Forms;
using SepehrTourApiSampleClient.Booking.Book.WinForms;
using SepehrTourApiSampleClient.Generic.WinForms;
using GetCheapestPrice = SepehrTourApiSampleClient.Availability.GetCheapestPrice.WinForms;

namespace SepehrTourApiSampleClient
{
    public partial class MainForm : Form
    {
        private readonly BookedPnrForm _bookedPnrForm;
        private readonly FailedRequestsForm _failedRequestsForm;
        private readonly GetCheapestPrice.GetCheapestPriceForm _getCheapestPriceForm;

        public MainForm()
        {
            InitializeComponent();

            
            _getCheapestPriceForm = new GetCheapestPrice.GetCheapestPriceForm(this);
            _getCheapestPriceForm.TopLevel = false;
            _getCheapestPriceForm.Parent = tbgSearchPackage;
            _getCheapestPriceForm.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";
                _getCheapestPriceForm.txtOriginIataCode.Text = "AWZ";
                _getCheapestPriceForm.txtDestinationIataCode.Text = "IFN";
            }
        }

        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();
        }
    }
}
