using System;
using System.Xml;
using System.IO;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;


public partial class Index : System.Web.UI.Page
{
    Hermes obj_Hermes;
    AirEpointSupport obj_AirEpointSupport;
    public string DepartDate_range;
    int TotalPassenger;
    string prfredairlines;
    protected void Page_Load(object sender, EventArgs e)    
    {
       // ViewState["HURL"] = Session["HURL"];
        Session["Currency"] = "INR";
        Session["convertor"] = "1";
        if (Session["agid"] == null)
        {
            Response.Redirect("~/login.aspx");
        }

        lbl_balance.Text = Convert.ToString(Convert.ToDouble(Session["agent_amount"]));
        if (!IsPostBack)
        {
            if (Request.QueryString.Count > 0)
            {
                string s = Request.QueryString[0];
                if (s == "NoFlight")
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('No flight is available.Please change the search criteria.')</script>");

                }
                else if (s == "pay" || s == "Pay")
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('You have insufficient balance for this booking.')</script>");

                }
                else if (s == "exception")
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('Technical error occured.Please try again.')</script>");

                }
                else if (s == "PricingError")
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('There is pricing verification error.Please try again.')</script>");

                }
                else if (s == "timeout")
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('Session Timeout.Please try again.')</script>");

                }
            }
        }
    

        obj_AirEpointSupport = new AirEpointSupport();
        DataSet ds = new DataSet();
        /*---------------------------------------Bind AirLineCheckBoxList---------------------------------------*/

        /*---------------------------------------Bind AirLineCheckBoxList---------------------------------------*/
        if (!IsPostBack)
        {

            CurrentMargin();
            get_markup();
            ds = obj_AirEpointSupport.GetAirPortDetails();
            AirPortList = ds.Tables[0];
            txt_departdate.Text = DateTime.Now.AddDays(0).ToString("dd-MMM-yyyy");
            txt_arrivaldate.Text = DateTime.Now.AddDays(1).ToString("dd-MMM-yyyy");
        }
        txt_departdate.Attributes.Add("readonly", "readonly");

        txt_arrivaldate.Attributes.Add("readonly", "readonly");
        #region Depart  Date Validation
        // Depart Date VALIDATION
        DateTime DepartMaxDate = new DateTime();
        DepartMaxDate = DateTime.Now.AddYears(10);

        DateTime DepartMinimumDate = new DateTime();
        DepartMinimumDate = DateTime.Now;


        string DepartMinYear = DepartMinimumDate.ToString("yyyy");
        string DepartMinMonth = DepartMinimumDate.ToString("MM");
        string DepartMinDay = DepartMinimumDate.ToString("dd");


        string DepartMaxYear = DepartMaxDate.ToString("yyyy");
        string DepartMaxMonth = DepartMaxDate.ToString("MM");
        string DepartMaxDay = DepartMaxDate.ToString("dd");
        DepartDate_range = "[[" + DepartMinYear + "," + DepartMinMonth + "," + DepartMinDay + "],[" + DepartMaxYear + "," + DepartMaxMonth + "," + DepartMaxDay + "]]";


        #endregion
    }
    protected void get_markup()
    {
        //SqlHelper acs = new SqlHelper();
        //acs.Get_DB(Convert.ToString(ViewState["HURL"]));
        try
        {
            DataSet ds;
            SqlParameter[] puneet = new SqlParameter[]
               {
                      new SqlParameter("@agent_id",Convert.ToString(Session["agid"]))
               };


            ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "getmarkup_new", puneet);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string mark = ds.Tables[0].Rows[0]["agent_markup"].ToString();
                Session["agentMarkup"] = Convert.ToDecimal(mark).ToString("f0");
                Session["allMarkup"] = ds.Tables[0].Rows[0]["all_markup"].ToString();
            }
            else
            {
                Session["agentMarkup"] = "0";
                Session["allMarkup"] = "0";
            }

        }
        catch (Exception ex)
        {
            Session["agentMarkup"] = "0";
            Session["allMarkup"] = "0";
        }

    }
    public static DataTable AirPortList;
    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetCompletionList(string prefixText, int count, string contextKey)
    {


        prefixText = AirEpointSupport.ToUpperFirstLetter(prefixText);

        var RESULT = (from table1 in AirPortList.AsEnumerable()
                      where table1.Field<string>("CityName").Contains(prefixText) || table1.Field<string>("CityCode").Contains(prefixText) || table1.Field<string>("Counrty").Contains(prefixText) || table1.Field<string>("AirPortDec").Contains(prefixText) ||
                     table1.Field<string>("CityName").Contains(prefixText.ToUpper()) || table1.Field<string>("CityCode").Contains(prefixText.ToUpper()) || table1.Field<string>("Counrty").Contains(prefixText.ToUpper()) || table1.Field<string>("AirPortDec").Contains(prefixText.ToUpper()) 
                      select table1).Distinct();

        DataTable dt = new DataTable();
        dt = RESULT.CopyToDataTable();
        DataSet _ds = new DataSet();
        _ds.Tables.Add(dt);
        List<string> CompletionSet = new List<string>();

        foreach (DataRow rdr in _ds.Tables[0].Rows)
        {
            string daaa = rdr["CityName"].ToString().ToUpper() + "," + rdr["AirPortDec"].ToString().ToUpper() + " (" + rdr["CityCode"].ToString().ToUpper() + ")";
            CompletionSet.Add(daaa.ToString());

        }

        return CompletionSet.ToArray();
    }



    protected void btn_submit_Click(object sender, EventArgs e)
    {

        try
        {
            bool validation = true;
            string msg = "";

            if (Convert.ToDateTime(DateTime.Now.ToShortDateString()) > Convert.ToDateTime(txt_departdate.Text))
            {
                validation = false;
                msg = "Depart date can not less than Current date.";
            }
            if (RadioButtonListtrip.SelectedIndex != 0 && (Convert.ToDateTime(txt_arrivaldate.Text) < Convert.ToDateTime(txt_departdate.Text)))
            {
                validation = false;
                msg = "Return date can not less than departure date.";
            }


            if (txt_from.Text.Trim() == "" || txt_from.Text == "Enter Origin City or Airport Name")
            {
                validation = false;
                msg = "Please enter origin city.";
            }

            if (txt_to.Text.Trim() == "" || txt_to.Text == "Enter Destination City or Airport Name")
            {
                validation = false;
                msg = "Please enter destination city";
            }

            if (validation)
            {
                get_markup();

                #region Submit Form

                int x = obj_AirEpointSupport.CheckSearchFlight(txt_from.Text, txt_to.Text);
                if (x == 1)
                {
                    #region Check preferred airlines
                    Checklist();
                    #endregion
                    #region Get search value in session
                    Session["From_Source"] = txt_from.Text;
                    Session["To_Source"] = txt_to.Text;
                    string DestinationFromValue = obj_AirEpointSupport.FindAirPortCode(txt_from.Text).Replace(")", "");
                    string DestinationToValue = obj_AirEpointSupport.FindAirPortCode(txt_to.Text).Replace(")", "");
                    Session["Destination_Value_"] = DestinationToValue;

                    string DestinationFrom = obj_AirEpointSupport.FindAirPortCityName(txt_from.Text);
                    string DestinationTo = obj_AirEpointSupport.FindAirPortCityName(txt_to.Text);
                    Session["Trip"] = RadioButtonListtrip.SelectedItem.Value.ToString();
                    Session["DestinationFrom"] = DestinationFrom.ToString();
                    Session["DestinationFromValue"] = DestinationFrom;
                    Session["DestinationTo"] = DestinationTo;
                    Session["DestinationToValue"] = DestinationTo;
                    Session["sourc"] = DestinationFromValue;
                    Session["Dest"] = DestinationToValue;
                    Session["DepartureDate"] = Convert.ToDateTime(txt_departdate.Text).ToString("yyyy-MMM-dd");

                    Session["DepartureDate1"] = Convert.ToDateTime(txt_departdate.Text).ToString("dd-MMM-yyyy");
                    Session["Adults"] = ddl_adult.SelectedItem.Value.ToString();

                    if (RadioButtonListtrip.SelectedIndex == 0)
                    {
                        Session["ReturnDate"] = DateTime.Parse(txt_departdate.Text).AddDays(1).ToString("yyyy-MMM-dd");
                        Session["ReturnDate1"] = Convert.ToDateTime(txt_departdate.Text).AddDays(1).ToString("dd-MMM-yyyy");
                    }
                    else
                    {
                        Session["ReturnDate"] = Convert.ToDateTime(txt_arrivaldate.Text).ToString("yyyy-MMM-dd");
                        Session["ReturnDate1"] = Convert.ToDateTime(txt_arrivaldate.Text).ToString("dd-MMM-yyyy");
                    }


                    Session["Children"] = ddl_child.SelectedItem.Value.ToString();
                    Session["Infants"] = ddl_infant.SelectedItem.Value.ToString();
                    Session["Class"] = ddl_class.SelectedItem.Value.ToString();
                    TotalPassenger = Convert.ToInt32(ddl_adult.SelectedItem.Value) + Convert.ToInt32(ddl_child.SelectedItem.Value);
                    Session.Remove("partnerRefId");

                    Random r = new Random();

                    Session["partnerRefId"] = obj_AirEpointSupport.Generate_TID();
                    string sss = Convert.ToString(Session["partnerRefId"]);
                    #endregion


                    #region When search Type is Domestic and Special fare
                    if (obj_AirEpointSupport.CheckSourceDestination(txt_from.Text, txt_to.Text) == "DOM")
                    {
                        //       Page.RegisterStartupScript("XXX", "<script> alert('Domestic Flight Searching is not available.')</script>");


                        #region Domestic Request
                        if (Convert.ToString(ViewState["flighttypelavi"]) != "DOM")
                        {
                            ViewState["selectedairlines"] = "";
                        }
                        Session["DestinationFrom"] = DestinationFrom;
                        Session["DestinationFromValue"] = DestinationFromValue;
                        Session["DestinationTo"] = DestinationTo;
                        Session["DestinationToValue"] = DestinationToValue;
                        Session["FlightType"] = "DOM";

                        #region Domestic  Request One Round
                        if (Convert.ToString(Session["Trip"]) == "One")
                        {
                            #region Domestic One Way Pass less than 9
                            if (TotalPassenger <= 9)
                            {
                                //  ViewState["selectedairlines"] = "AI,G8,IC,6E,9W,S2,IT,9H,I7,SG,IX";
                                string DD = DateTime.Parse(txt_departdate.Text).Day.ToString();
                                string MM = DateTime.Parse(txt_departdate.Text).Month.ToString();
                                if (MM.Length < 2)
                                {
                                    MM = "0" + MM;
                                }
							    if (DD.Length < 2)
                                {
                                    DD = "0" + DD;
                                }
                                string yy = DateTime.Parse(txt_departdate.Text).Year.ToString();
                                txt_arrivaldate.Text = MM + "/" + DD + "/" + yy;
                                string request_Avail = @"<AvailabilityReq><BookingType>O</BookingType><JryDetails><Item><Origin>" + DestinationFromValue + @"</Origin><Destination>" + DestinationToValue + @"</Destination>
<TravelDate>" + txt_arrivaldate.Text + @"</TravelDate></Item></JryDetails><ClassType>Economy</ClassType>
<Airlinecodes></Airlinecodes><Adults>" + ddl_adult.SelectedItem.Value.ToString() + @"</Adults><Childs>" + ddl_child.SelectedItem.Value.ToString() + @"</Childs>
<Infants>" + ddl_infant.SelectedItem.Value.ToString() + @"</Infants>
<ResidentofIndia>1</ResidentofIndia><DirectAccess>0</DirectAccess><TransFeeFlag>1</TransFeeFlag></AvailabilityReq>";
                                Hermes obj_hermes = new Hermes();
                                DataSet ds = new DataSet();
								obj_AirEpointSupport.WriteXmlLog(request_Avail, "Domestic_Avialable_Request__" + Convert.ToString("12317123"));
                                string response_avail = obj_hermes.AirAvailability(request_Avail);
                                //Session["Response"] = ds;
                                obj_AirEpointSupport.WriteXmlLog(response_avail, "Domestic_Avialable_Respnse__" + Convert.ToString("12312123"));
                                Session["myResult"] = response_avail;
                                ds.ReadXml(new StringReader(response_avail));
                                Session["Response"] = ds;



                                Response.Redirect("../Domestic/OneWayResult.aspx", false);
                            }
                            else
                            {
                                Page.RegisterStartupScript("XXX", "<script> alert('Sum of Adult and child passenger travelling not more than 9')</script>");
                            }
                            #endregion
                        }



                        else if (Convert.ToString(Session["Trip"]) == "Round")
                        {
                            #region Domestic Round Trip Pass less than 9
                            if (TotalPassenger <= 9)
                            {
                                //   ViewState["selectedairlines"] = "AI,G8,IC,6E,9W,S2,IT,9H,I7,SG,IX";
                               // txt_departdate.Text = DateTime.Parse(txt_departdate.Text).ToString("MM/dd/yyyy");
                                string DD = DateTime.Parse(txt_departdate.Text).Day.ToString();
                                string MM = DateTime.Parse(txt_departdate.Text).Month.ToString();
                                if (MM.Length < 2)
                                {
                                    MM = "0" + MM;
                                }
                                string yy = DateTime.Parse(txt_departdate.Text).Year.ToString();
                                txt_departdate.Text = MM + "/" + DD + "/" + yy;

                                string DD1 = DateTime.Parse(txt_arrivaldate.Text).Day.ToString();
                                string MM1 = DateTime.Parse(txt_arrivaldate.Text).Month.ToString();
                                if (MM1.Length < 2)
                                {
                                    MM1 = "0" + MM1;
                                }
                                string yy1 = DateTime.Parse(txt_arrivaldate.Text).Year.ToString();
                                txt_arrivaldate.Text = MM1 + "/" + DD1 + "/" + yy1;
                              //  txt_arrivaldate.Text = DateTime.Parse(txt_arrivaldate.Text).ToString("MM/dd/yyyy");

                                string request_Avail = @"<AvailabilityReq><BookingType>R</BookingType><JryDetails><Item><Origin>" + DestinationFromValue + @"</Origin><Destination>" + DestinationToValue + @"</Destination>
<TravelDate>" + txt_departdate.Text + @"</TravelDate></Item><Item><Origin>" + DestinationToValue + @"</Origin><Destination>" + DestinationFromValue + @"</Destination>
<TravelDate>" + txt_arrivaldate.Text + @"</TravelDate></Item></JryDetails><ClassType>Economy</ClassType>
<Airlinecodes></Airlinecodes><Adults>" + ddl_adult.SelectedItem.Value.ToString() + @"</Adults><Childs>" + ddl_child.SelectedItem.Value.ToString() + @"</Childs>
<Infants>" + ddl_infant.SelectedItem.Value.ToString() + @"</Infants>
<ResidentofIndia>1</ResidentofIndia><DirectAccess>0</DirectAccess><TransFeeFlag>1</TransFeeFlag></AvailabilityReq>";
                                Hermes obj_hermes = new Hermes();
                                DataSet ds = new DataSet();
                                string response_avail = obj_hermes.AirAvailability(request_Avail);
                                //Session["Response"] = ds;
                                Session["myResult"] = response_avail;
                                ds.ReadXml(new StringReader(response_avail));
                                Session["Response"] = ds;

                                Response.Redirect("../Domestic/RoundTripResult.aspx", false);

                            }
                            else
                            {
                                Page.RegisterStartupScript("XXX", "<script> alert('Sum of Adult and child passenger travelling not more than 9')</script>");
                            }
                            #endregion
                        }

                        #endregion
                        #endregion

                    }


                    #endregion


                    #region FOR INTERNATIONAL FLIGHT
                    //else if (obj_AirEpointSupport.CheckSourceDestination(txt_from.Text, txt_to.Text) == "INAIR" || obj_AirEpointSupport.CheckSourceDestination(txt_from.Text, txt_to.Text) == "SETO")
                    //{



                    //    #region Send International Request
                    //    Session["FlightType"] = "INAIR";
                    //    if (Convert.ToString(ViewState["flighttypelavi"]) != "INAIR")
                    //    {
                    //        ViewState["selectedairlines"] = "";
                    //    }

                    //    #region international oneway
                    //    if (Convert.ToString(Session["Trip"]) == "One")
                    //    {
                    //        if (true)
                    //        {


                    //            if (TotalPassenger <= 9)
                    //            {
                    //                #region Sending Request
                    //                txt_arrivaldate.Text = DateTime.Parse(txt_departdate.Text).AddDays(2).ToString("MM/dd/yyyy");
                    //                string Request = "<AvailabilityReq><BookingType>O</BookingType><Details><Item><Source>" + DestinationFromValue + "</Source><Destination>" + DestinationToValue + "</Destination><Date>" + DateTime.Parse(txt_departdate.Text).ToString("MM/dd/yyyy") + "</Date></Item></Details><ClassTypeId>Economy</ClassTypeId><AIRLINES /><Adult>" + Convert.ToInt16(ddl_adult.SelectedItem.Value.ToString()) + "</Adult><Child>" + Convert.ToInt16(ddl_child.SelectedItem.Value.ToString()) + "</Child><Infant>" + Convert.ToInt16(ddl_infant.SelectedItem.Value.ToString()) + "</Infant><ResidentofIndia>1</ResidentofIndia><AirlineCode></AirlineCode><DirectAccess>0</DirectAccess></AvailabilityReq>";


                    //                //  string Request = "<AvailRequest><Trip>ONE</Trip><Origin>" + DestinationFromValue + "</Origin><Destination>" + DestinationToValue + "</Destination><DepartDate>" + Convert.ToDateTime(txt_departdate.Text).ToString("yyyy-MM-dd") + "</DepartDate><ReturnDate>" + Convert.ToDateTime(txt_arrivaldate.Text).ToString("yyyy-MM-dd") + "</ReturnDate><AdultPax>" + ddl_adult.SelectedItem.Value.ToString() + "</AdultPax><ChildPax>" + ddl_child.SelectedItem.Value.ToString() + "</ChildPax><InfantPax>" + ddl_infant.SelectedItem.Value.ToString() + "</InfantPax><Currency>INR</Currency><PreferredClass>" + ddl_class.SelectedValue.ToString() + "</PreferredClass><Eticket>true</Eticket><Clientid>" + intClientid + "</Clientid><Clientpassword>" + intClientpassword + "</Clientpassword><Clienttype>" + intClienttype + "</Clienttype><PreferredAirline>" + (string)ViewState["selectedairlines"] + "</PreferredAirline></AvailRequest>";
                    //                Session.Remove("Response");
                    //                obj_AirEpointSupport.WriteXmlLog(Request, "International_Request");


                    //                obj_Hermes = new Hermes();
                    //                string Response_result = obj_Hermes.Inter_AirAvailability(Request);
                    //                obj_AirEpointSupport.WriteXmlLog(Response_result, "International_Response");
                    //                Session["Response"] = Response_result;

                    //                #region Check Reponse is null or not
                    //                if (Response_result != "")
                    //                {


                    //                    Response.Redirect("../Hermes/International/OneWayInternational.aspx", false);

                    //                }
                    //                else if (Response_result == "")
                    //                {
                    //                    Response.Redirect("../User/index.aspx?s=OnFlight", false);
                    //                }
                    //                #endregion
                    //                #endregion
                    //            }

                    //            else
                    //            {
                    //                Page.RegisterStartupScript("XXX", "<script> alert('Sum of Adult and child passenger travelling not more than 9')</script>");
                    //            }
                    //        }
                    //        else
                    //        {
                    //            Page.RegisterStartupScript("XXX", "<script> alert('Depart date should be later than current date in International flights.')</script>");
                    //        }

                    //    }
                    //    #endregion

                    //    #region International Round
                    //    else if (Convert.ToString(Session["Trip"]) == "Round")
                    //    {
                    //        if (false)
                    //        {


                    //            Page.RegisterStartupScript("XXX", "<script> alert('Return Date Cannot be less than Depart Date')</script>");

                    //        }
                    //        else
                    //        {
                    //            if (TotalPassenger <= 9)
                    //            {
                    //                string Request = "<AvailabilityReq><BookingType>R</BookingType><Details><Item><Source>" + DestinationFromValue + "</Source><Destination>" + DestinationToValue + "</Destination><Date>" + DateTime.Parse(txt_departdate.Text).ToString("MM/dd/yyyy") + "</Date></Item><Item><Source>" + DestinationToValue + "</Source><Destination>" + DestinationFromValue + "</Destination><Date>" + DateTime.Parse(txt_arrivaldate.Text).ToString("MM/dd/yyyy") + "</Date></Item></Details><ClassTypeId>Economy</ClassTypeId><AIRLINES /><Adult>" + Convert.ToInt16(ddl_adult.SelectedItem.Value.ToString()) + "</Adult><Child>" + Convert.ToInt16(ddl_child.SelectedItem.Value.ToString()) + "</Child><Infant>" + Convert.ToInt16(ddl_infant.SelectedItem.Value.ToString()) + "</Infant><ResidentofIndia>1</ResidentofIndia><AirlineCode></AirlineCode><DirectAccess>0</DirectAccess></AvailabilityReq>";

                    //                Session.Remove("Response");
                    //                obj_AirEpointSupport.WriteXmlLog(Request, "International_Request_Round");
                    //                //string Response_result = obj_AirEpointSupport.sendRequestAndGetResponse_Arzoo(IntAvalability, Request);
                    //                obj_Hermes = new Hermes();
                    //                string Response_result = obj_Hermes.Inter_AirAvailability(Request);
                    //                obj_AirEpointSupport.WriteXmlLog(Response_result, "International_Response_Round");
                    //                Session["Response"] = Response_result;
                    //                DataSet DsAirLineDetail = new DataSet();
                    //                DsAirLineDetail.ReadXml(new StringReader(Convert.ToString(Session["Response"])));
                    //                if (Response_result != null)
                    //                {
                    //                    if (Response_result != null)
                    //                    {

                    //                        Response.Redirect("../Hermes/international/RoundTripResultInternational.aspx", false);

                    //                    }
                    //                    else if (Response_result == null)
                    //                    {
                    //                        Session["NoFlight"] = 1;
                    //                        Response.Redirect("../User/index.aspx?s=NoFlight", false);
                    //                    }
                    //                }
                    //                else if (Response_result == null)
                    //                {
                    //                    Response.Redirect("../User/index.aspx?s=NoFlight", false);
                    //                }
                    //            }

                    //            else
                    //            {
                    //                Page.RegisterStartupScript("XXX", "<script> alert('Sum of Adult and child passenger travelling not more than 9')</script>");
                    //            }

                    //        }
                    //    }
                    //    #endregion
                    //    #endregion


                    //}
                    #endregion


                }



                else if (x == 0)
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('Source and Destination names does not exist.')</script>");
                }


                #endregion
            }
            else
            {
                RegisterClientScriptBlock("alert", "<script>alert('" + msg + "');</script>");
            }

        }

        catch (Exception ex)
        {
            txt_to.Text = "Enter Destination City or Airport Name";
            txt_from.Text = "Enter Origin City or Airport Name";
            RegisterClientScriptBlock("alert", "<script>alert('" + ex.Message + "');</script>");
        }
    }


    private void Checklist()
    {
        try
        {

            CheckBoxList list = CheckBoxList_Airlines;
            if (list.Items.Count > 0)
            {
                int count = 0;
                foreach (ListItem item in list.Items)
                {
                    if (item.Selected)
                    {
                        prfredairlines += item.Value + ",";
                        count += 1;
                    }
                }
                if (count == 0)
                {
                    foreach (ListItem item in list.Items)
                    {

                        prfredairlines += item.Value + ",";


                    }

                }

                ViewState["selectedairlines"] = prfredairlines.Remove(prfredairlines.Length - 1, 1);
            }
            else
            {
                ViewState["selectedairlines"] = "";
            }



        }
        catch (Exception ex)
        {
          //  Air_transaction_Cal.writeToLogFile("BookingProcess_DomesticInterNational.aspx-Checklist()" + ex.Message.ToString(), Server.MapPath("~/Air_InternaltionalExceptionList"));
            ViewState["selectedairlines"] = "";
        }
    }

    protected void linkbuttonprefferd_Click(object sender, EventArgs e)
    {
        int x = obj_AirEpointSupport.CheckSearchFlight(txt_from.Text, txt_to.Text);
        if (x == 1)
        {
            if (obj_AirEpointSupport.CheckSourceDestination(txt_from.Text, txt_to.Text) == "INAIR" || obj_AirEpointSupport.CheckSourceDestination(txt_from.Text, txt_to.Text) == "SETO")
            {
                DataSet ds1 = new DataSet();
                ds1 = obj_AirEpointSupport.GetAirLineDetails();
                var AirLinesName1 = from Airline in ds1.Tables["AirLine"].AsEnumerable()
                                    where Airline.Field<string>("Type") == "INAIR"
                                    select Airline;
                DataTable dt1 = AirLinesName1.CopyToDataTable();
                CheckBoxList_Airlines.DataSource = dt1;
                CheckBoxList_Airlines.DataValueField = "AirLineCode";
                CheckBoxList_Airlines.DataTextField = "AirLineName";
                CheckBoxList_Airlines.Width = 800;
                CheckBoxList_Airlines.RepeatColumns = 5;
                CheckBoxList_Airlines.DataBind();
                //  uniquename3.Visible = true;
                lblmsg.Visible = false;
                //  uniquename3.Visible = true;
                modalpopup1.Show();
                CheckBoxList_Airlines.Visible = true;
                ViewState["flighttypelavi"] = "INAIR";
            }
            else
            {
                DataSet ds1 = new DataSet();
                ds1 = obj_AirEpointSupport.GetAirLineDetails();
                var AirLinesName1 = from Airline in ds1.Tables["AirLine"].AsEnumerable()
                                    where Airline.Field<string>("Type") == "DOM"
                                    select Airline;
                DataTable dt1 = AirLinesName1.CopyToDataTable();
                CheckBoxList_Airlines.DataSource = dt1;
                CheckBoxList_Airlines.DataValueField = "AirLineCode";
                CheckBoxList_Airlines.DataTextField = "AirLineName";
                CheckBoxList_Airlines.Width = 400;
                CheckBoxList_Airlines.RepeatColumns = 3;
                CheckBoxList_Airlines.DataBind();
                //   uniquename3.Visible = true;
                modalpopup1.Show();
                lblmsg.Visible = false;
                CheckBoxList_Airlines.Visible = true;
                ViewState["flighttypelavi"] = "DOM";
            }
        }
        else
        {
            //     uniquename3.Visible = true;
            modalpopup1.Show();
            lblmsg.Visible = true;
            CheckBoxList_Airlines.Visible = false;
            ViewState["flighttypelavi"] = "";
        }
    }
    public void CurrentMargin()
    {
        lbl_current_date.Text = Convert.ToDateTime(System.DateTime.Now.ToShortDateString()).ToString("MMM-yyyy");
        SqlParameter[] Margin = new SqlParameter[]
        {
            new SqlParameter("@Agentid",Session["LOGINID"].ToString())
        };
        SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "SP_GETCOMMISSIONOFMONTH", Margin);
        if (dr.Read())
        {
            lbl_COMMISSION.Text = Convert.ToString(dr["Margin"]);
            if (lbl_COMMISSION.Text == "")
            {
                lbl_COMMISSION.Text = "0.00";
            }
            else
            {
                lbl_COMMISSION.Text = Convert.ToString(dr["Margin"]);
            }
        }
    }
}

