protected void btnIntBook_Click(object sender, EventArgs e)
    {
        if (Session["UserID"] == null) { Response.Redirect("~/Default.aspx", false); return; }
        ClsBAL objBAL = new ClsBAL();
        DataSet dsBookingResponse = new DataSet();

        //if (Session["Role"].ToString() == "Agent")
        //{

        DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));

        DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "InterNationalFlights",lblairline.Text); // Change it
        string commisionPercentage = string.Empty;
        if (dsCommSlab.Tables[0].Rows.Count > 0)
            commisionPercentage = dsCommSlab.Tables[0].Rows[0]["Commission"].ToString();// Change it
        else
            commisionPercentage = "0";

        string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
          //  string commisionPercentage = dsBalance.Tables[0].Rows[0]["CommisionPercentage"].ToString();
        string agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

        string actualFare = Session["TotalFare"].ToString();

        string deductAmount = Convert.ToString(Convert.ToDouble(actualFare.ToString()) -
            ((Convert.ToDouble(actualFare.ToString()) * Convert.ToDouble(commisionPercentage)) / 100));
        string commisionFare = Convert.ToString(Convert.ToDouble(actualFare.ToString()) - Convert.ToDouble(deductAmount));

        Session["AgentId_Agent"] = agentId;
        Session["ActualFare_Agent"] = actualFare;
        Session["CommisionFare_Agent"] = commisionFare;
        Session["CommisionPercentage_Agent"] = commisionPercentage;
        Session["DeductAmount_Agent"] = deductAmount;

        if (Convert.ToDouble(balance) >= Convert.ToDouble(deductAmount))
        {
            dsBookingResponse = GetIntBookingRequest();
        }
        else { lblMsg.Text = "Please contact administrator."; return; }
        //}
        //else if (Session["Role"].ToString() == "User")
        //{

        //}

        #region Save Response
        FlightBAL objFlightBal = new FlightBAL();
        if (dsBookingResponse.Tables.Count > 0)
        {
            if (dsBookingResponse.Tables["BookingResponse"].Rows.Count > 0)
            {
                objFlightBal.ReferenceNo = Common.GetFlightsReferenceNo("LJIF");
                objFlightBal.TransId = dsBookingResponse.Tables["BookingResponse"].Rows[0]["transid"].ToString();
                objFlightBal.Status = dsBookingResponse.Tables["BookingResponse"].Rows[0]["status"].ToString();
                objFlightBal.AdultPax = Convert.ToInt32(dsBookingResponse.Tables["BookingResponse"].Rows[0]["noadults"].ToString());
                objFlightBal.InfantPax = Convert.ToInt32(dsBookingResponse.Tables["BookingResponse"].Rows[0]["noinfant"].ToString());
                objFlightBal.ChildPax = Convert.ToInt32(dsBookingResponse.Tables["BookingResponse"].Rows[0]["nochild"].ToString());
                objFlightBal.Origin_Destination_Id = dsBookingResponse.Tables["OriginDestinationOption"].Rows[0]["id"].ToString();
                objFlightBal.Origin_Destination_Key = dsBookingResponse.Tables["OriginDestinationOption"].Rows[0]["key"].ToString();
                objFlightBal.ActualBasefare = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["ActualBasefare"].ToString());
                objFlightBal.Tax = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["Tax"].ToString());
                objFlightBal.STax = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["STax"].ToString());
                objFlightBal.TCharge = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["TCharge"].ToString());
                objFlightBal.Scharge = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["Scharge"].ToString());
                objFlightBal.TDiscount = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["TDiscount"].ToString());
                objFlightBal.TMarkUp = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["TMarkUp"].ToString());
                objFlightBal.TPartnerCommission = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["TPartnerCommission"].ToString());
                objFlightBal.TSDiscount = Convert.ToDecimal(dsBookingResponse.Tables["FareDetails"].Rows[0]["TSDiscount"].ToString());
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                objFlightBal.TripMode = "One";

                DataTable dtflightBookingId = objFlightBal.AddDInternationalFlightBooking(objFlightBal);
                string flightBookingId = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();

                //Do the Insert of Flgiht Segment

                objFlightBal.FlightBookingID = flightBookingId.ToString();
                if (dsBookingResponse.Tables["FlightSegment"].Rows.Count > 0)
                {
                    for (int j = 0; j < dsBookingResponse.Tables["FlightSegment"].Rows.Count; j++)
                    {
                        objFlightBal.AirEquipType = dsBookingResponse.Tables["FlightSegment"].Rows[j]["AirEquipType"].ToString();
                        objFlightBal.ArrivalAirportCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ArrivalAirportCode"].ToString();
                        objFlightBal.ArrivalAirportName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ArrivalAirportName"].ToString();
                        objFlightBal.ArrivalDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ArrivalDateTime"].ToString();
                        objFlightBal.DepartureAirportCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureAirportCode"].ToString();
                        objFlightBal.DepartureAirportName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureAirportName"].ToString();
                        objFlightBal.DepartureDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureDateTime"].ToString();
                        objFlightBal.FlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["FlightNumber"].ToString();
                        objFlightBal.MarketingAirlineCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["MarketingAirlineCode"].ToString();
                        objFlightBal.OperatingAirlineCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineCode"].ToString();
                        objFlightBal.OperatingAirlineName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineName"].ToString();
                        objFlightBal.OperatingAirlineFlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineFlightNumber"].ToString();
                        objFlightBal.NumStops = dsBookingResponse.Tables["FlightSegment"].Rows[j]["NumStops"].ToString();
                        objFlightBal.LinkSellAgrmnt = dsBookingResponse.Tables["FlightSegment"].Rows[j]["LinkSellAgrmnt"].ToString();
                        objFlightBal.Conx = dsBookingResponse.Tables["FlightSegment"].Rows[j]["Conx"].ToString();
                        objFlightBal.AirpChg = dsBookingResponse.Tables["FlightSegment"].Rows[j]["AirpChg"].ToString();
                        objFlightBal.InsideAvailOption = dsBookingResponse.Tables["FlightSegment"].Rows[j]["InsideAvailOption"].ToString();
                        objFlightBal.GenTrafRestriction = dsBookingResponse.Tables["FlightSegment"].Rows[j]["GenTrafRestriction"].ToString();
                        objFlightBal.DaysOperates = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DaysOperates"].ToString();
                        objFlightBal.JrnyTm = dsBookingResponse.Tables["FlightSegment"].Rows[j]["JrnyTm"].ToString();
                        objFlightBal.EndDt = dsBookingResponse.Tables["FlightSegment"].Rows[j]["EndDt"].ToString();
                        objFlightBal.StartTerminal = dsBookingResponse.Tables["FlightSegment"].Rows[j]["StartTerminal"].ToString();
                        objFlightBal.EndTerminal = dsBookingResponse.Tables["FlightSegment"].Rows[j]["EndTerminal"].ToString();
                        objFlightBal.FltTm = dsBookingResponse.Tables["FlightSegment"].Rows[j]["FltTm"].ToString();
                        objFlightBal.LSAInd = dsBookingResponse.Tables["FlightSegment"].Rows[j]["LSAInd"].ToString();
                        objFlightBal.Mile = dsBookingResponse.Tables["FlightSegment"].Rows[j]["Mile"].ToString();
                        objFlightBal.Availability = dsBookingResponse.Tables["BookingClass"].Rows[j]["Availability"].ToString();
                        objFlightBal.BIC = dsBookingResponse.Tables["BookingClass"].Rows[j]["BIC"].ToString();
                        objFlightBal.emailAddress = dsBookingResponse.Tables["email"].Rows[0]["emailAddress"].ToString();
                        objFlightBal.telephone = dsBookingResponse.Tables["telephone"].Rows[0]["PhoneNumber"].ToString();
                        objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                        string givenName = string.Empty;
                        string surName = string.Empty;
                        string namereference = string.Empty;
                        string psgrType = string.Empty;
                        string customerInfo = string.Empty;
                        string Age = string.Empty;
                        for (int i = 0; i < dsBookingResponse.Tables["CustomerInfo"].Rows.Count; i++)
                        {

                            givenName = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["givenName"].ToString();
                            surName = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["surName"].ToString();
                            namereference = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["nameReference"].ToString();
                            psgrType = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["psgrtype"].ToString();

                            if (dsBookingResponse.Tables["CustomerInfo"].Columns.Contains("age"))
                            {
                                Age = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["age"].ToString();
                                if (customerInfo == string.Empty)
                                {
                                    customerInfo = namereference + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                                else
                                {
                                    customerInfo = customerInfo + ";" + namereference + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                            }
                            else
                            {
                                Age = "-";
                                if (customerInfo == string.Empty)
                                {
                                    customerInfo = namereference + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                                else
                                {
                                    customerInfo = customerInfo + ";" + namereference + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                            }

                        }
                        objFlightBal.Customer_Details = customerInfo;

                        objFlightBal.bookingClass = dsBookingResponse.Tables["BookingClassFare"].Rows[0]["bookingClass"].ToString();
                        objFlightBal.ClassType = dsBookingResponse.Tables["BookingClassFare"].Rows[0]["ClassType"].ToString();
                        objFlightBal.farebasisCode = dsBookingResponse.Tables["BookingClassFare"].Rows[0]["farebasisCode"].ToString();
                        objFlightBal.Fare_Rule = dsBookingResponse.Tables["BookingClassFare"].Rows[0]["Rule"].ToString();
                        objFlightBal.PsgrType = dsBookingResponse.Tables["psgr"].Rows[0]["PsgrType"].ToString();
                        objFlightBal.BaseFare = dsBookingResponse.Tables["psgr"].Rows[0]["BaseFare"].ToString();
                        objFlightBal.psgrTax = dsBookingResponse.Tables["psgr"].Rows[0]["Tax"].ToString();
                        objFlightBal.BagInfo = dsBookingResponse.Tables["psgr"].Rows[0]["BagInfo"].ToString();

                        bool res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);

                        if (res1)
                        {
                            string[] commPer = Session["CommisionPercentage_Agent"].ToString().Split('.');
                            DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(Session["DeductAmount_Agent"].ToString()),
                                       Convert.ToInt32(Session["UserID"].ToString()), objFlightBal.ReferenceNo.ToString(), Convert.ToDouble(Session["ActualFare_Agent"].ToString()),
                                       Convert.ToDouble(Session["CommisionFare_Agent"].ToString()), Convert.ToInt32(commPer[0]));

                            objBAL = new ClsBAL();
                            DataSet dsBalanceA = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));

                            string balanceAgent = dsBalanceA.Tables[0].Rows[0]["Balance"].ToString();
                            Label lbl = (Label)this.Master.FindControl("lblBalance");
                            lbl.Text = balance;
                            Session["Balance"] = balanceAgent;

                            GetIntBookingStatus(objFlightBal.ReferenceNo.ToString());
                            GetDetailsForPrint(objFlightBal.ReferenceNo.ToString());

                        }

                    }

                    lbtnmail.Visible = false;
                    pnlIntPassengerDet.Visible = false;
                    lblMsg.Visible = true;
                    lblMsg.Text = "Ticket has been booked successfully. Reference Number is : " + objFlightBal.ReferenceNo.ToString();
                    lblMsg.ForeColor = System.Drawing.Color.Green;
                    lbtnmail_Click1(sender, e);
                }
            }
        }

        #endregion
    }
    private DataSet GetIntBookingRequest()
    {
        DataSet ds = new DataSet();

        #region Variables

        string str = string.Empty;
        string FlightSegmentsID = string.Empty;
        string DepartureAirportCode = string.Empty;
        string ArrivalDateTime = string.Empty;
        string DepartureAirportName = string.Empty;
        string DepartureDateTime = string.Empty;
        string FlightNumber = string.Empty;
        string MarketingAirlineCode = string.Empty;
        string OperatingAirlineCode = string.Empty;
        string OperatingAirlineName = string.Empty;
        string OperatingAirlineFlightNumber = string.Empty;
        string NumStops = string.Empty;
        string LinkSellAgrmnt = string.Empty;
        string Conx = string.Empty;
        string AirpChg = string.Empty;
        string InsideAvailOption = string.Empty;
        string GenTrafRestriction = string.Empty;
        string DaysOperates = string.Empty;
        string JrnyTm = string.Empty;
        string EndDt = string.Empty;
        string StartTerminal = string.Empty;
        string EndTerminal = string.Empty;
        string FltTm = string.Empty;
        string LSAInd = string.Empty;
        string Mile = string.Empty;
        string Availability = string.Empty;
        string BIC = string.Empty;
        string bookingclass = string.Empty;
        string classType = string.Empty;
        string farebasiscode = string.Empty;
        string Rule = string.Empty;
        string PsgrType = string.Empty;
        string BaseFare = string.Empty;
        string Tax = string.Empty;
        string BagInfo = string.Empty;
        string AirEquipType = string.Empty;
        string ArrivalAirportCode = string.Empty;
        string ArrivalAirportName = string.Empty;
        string return1 = string.Empty;
        string id = string.Empty;
        string key = string.Empty;
        string ActualBaseFare = string.Empty;
        string FareTax = string.Empty;
        string STax = string.Empty;
        string TCharge = string.Empty;
        string SCharge = string.Empty;
        string TDiscount = string.Empty;
        string TMarkup = string.Empty;
        string TPartnerCommission = string.Empty;
        string TSdiscount = string.Empty;
        string FarePsgrType = string.Empty;
        string FareBaseFare = string.Empty;
        string FareTax1 = string.Empty;
        string Country = string.Empty;
        string Amt = string.Empty;
        string ocTax = string.Empty;
        string onwardId = string.Empty;
        string OriginDestinationOption_Id = string.Empty;
        string FareDetails_id = string.Empty;
        string FareBreakUp_Id = string.Empty;
        string FareAry_id = string.Empty;
        string FareId = string.Empty;
        string bookingclassFareId = string.Empty;
        string psgrBreakUp_Id = string.Empty;
        string psgrAy_id = string.Empty;
        string country = string.Empty;
        string taxAmt = string.Empty;
        string taxData = string.Empty;
        string taxDataAry_id = string.Empty;

        string faretype = string.Empty;

        string CFareId = string.Empty;
        string CPsgrType = string.Empty;
        string CBaseFare = string.Empty;
        string CFareTax = string.Empty;
        string IFareId = string.Empty;
        string IPsgrType = string.Empty;
        string IBaseFare = string.Empty;
        string IFareTax = string.Empty;

        string CFarePsgrType = string.Empty;
        string CFareBaseFare = string.Empty;
        string CFareTax1 = string.Empty;
        string CBagInfo = string.Empty;
        string IFarePsgrType = string.Empty;
        string IFareBaseFare = string.Empty;
        string IFareTax1 = string.Empty;
        string IBagInfo = string.Empty;
        string taxdatapsgr = string.Empty;

        #endregion
        try
        {
            dsIntFlights = (DataSet)Session["dsIntFlights"];
            string result = null;
            DataTable dtFlightSegment = dsIntFlights.Tables[12];
            if (dtFlightSegment.Rows.Count > 0)
            {
                DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegment_ID=" + Convert.ToInt32(lblIntFlightSegmentId.Text));
                FlightSegmentsID = rowFilghtSegment[0]["FlightSegments_Id"].ToString();

            }
            DataTable dtFlightSegments = dsIntFlights.Tables[11];
            if (dtFlightSegments.Rows.Count > 0)
            {
                DataRow[] rowFilghtSegments = dtFlightSegments.Select("FlightSegments_ID=" + FlightSegmentsID);
                onwardId = rowFilghtSegments[0]["Onward_Id"].ToString();
            }
            DataTable dtOnward = dsIntFlights.Tables[10];
            if (dtOnward.Rows.Count > 0)
            {
                DataRow[] rowOnward = dtOnward.Select("Onward_Id=" + onwardId);
                OriginDestinationOption_Id = rowOnward[0]["OriginDestinationOption_Id"].ToString();
            }
            DataTable dtOriginDestinationOption = dsIntFlights.Tables[3];
            if (dtOriginDestinationOption.Rows.Count > 0)
            {
                DataRow[] rowOriginDestinationOption = dtOriginDestinationOption.Select("OriginDestinationOption_Id=" + OriginDestinationOption_Id);
                return1 = rowOriginDestinationOption[0]["Return"].ToString();
                id = rowOriginDestinationOption[0]["id"].ToString();
                key = rowOriginDestinationOption[0]["key"].ToString();
            }
            DataTable dtFareDetails = dsIntFlights.Tables[4];
            if (dtFareDetails.Rows.Count > 0)
            {
                DataRow[] rowFareDetails = dtFareDetails.Select("OriginDestinationOption_Id=" + OriginDestinationOption_Id);
                ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                Tax = rowFareDetails[0]["Tax"].ToString();
                STax = rowFareDetails[0]["STax"].ToString();
                TCharge = rowFareDetails[0]["TCharge"].ToString();
                SCharge = rowFareDetails[0]["SCharge"].ToString();
                TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                ocTax = rowFareDetails[0]["ocTax"].ToString();
                FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
            }
            DataTable dtFareBreakUp = dsIntFlights.Tables[5];
            if (dtFareBreakUp.Rows.Count > 0)
            {
                DataRow[] rowFareBreakUp = dtFareBreakUp.Select("FareDetails_Id=" + FareDetails_id);
                FareBreakUp_Id = rowFareBreakUp[0]["FareBreakUp_Id"].ToString();

            }
            DataTable dtFareAry = dsIntFlights.Tables[6];
            if (dtFareAry.Rows.Count > 0)
            {
                DataRow[] rowFareAry = dtFareAry.Select("FareBreakUp_Id=" + FareBreakUp_Id);
                FareAry_id = rowFareAry[0]["FareAry_id"].ToString();
            }
            DataTable dtFare = dsIntFlights.Tables[7];
            if (dtFare.Rows.Count > 0)
            {
                DataRow[] rowFare = dtFare.Select("FareAry_id=" + FareAry_id);

                PsgrType = rowFare[0]["PsgrType"].ToString();
                BaseFare = rowFare[0]["BaseFare"].ToString();
                FareTax = rowFare[0]["Tax"].ToString();
                FareId = rowFare[0]["Fare_Id"].ToString();
                Session["FareId"] = FareId.ToString();

                foreach (DataRow dr in rowFare)
                {
                    if (faretype == "")
                    {
                        faretype = dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString();
                    }
                    else
                    {

                        faretype = faretype + ";" + dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString() + ";";
                    }
                }

            }

            DataTable dtBookingClass = dsIntFlights.Tables[13];
            if (dtBookingClass.Rows.Count > 0)
            {
                DataRow[] rowBookingClass = dtBookingClass.Select("FlightSegment_Id=" + lblIntFlightSegmentId.Text);
                Availability = rowBookingClass[0]["Availability"].ToString();
                BIC = rowBookingClass[0]["BIC"].ToString();
            }
            DataTable dtBookingClassFare = dsIntFlights.Tables[14];
            if (dtBookingClassFare.Rows.Count > 0)
            {
                DataRow[] rowBookingClassFare = dtBookingClassFare.Select("FlightSegment_Id=" + lblIntFlightSegmentId.Text);
                bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                classType = rowBookingClassFare[0]["classType"].ToString();
                farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                Rule = rowBookingClassFare[0]["Rule"].ToString();
                if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                {
                    bookingclassFareId = rowBookingClassFare[0]["bookingclassFare_Id"].ToString();
                }

            }
            //Non Mandatory fields
            if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
            {
                DataTable dtPsgrBreakUp = dsIntFlights.Tables[15];
                if (dtPsgrBreakUp.Rows.Count > 0)
                {
                    DataRow[] rowPsgrBreakUp = dtPsgrBreakUp.Select("bookingclassFare_Id=" + bookingclassFareId);
                    psgrBreakUp_Id = rowPsgrBreakUp[0]["psgrBreakUp_Id"].ToString();

                }
                DataTable dtPsgrAry = dsIntFlights.Tables[16];
                if (dtPsgrAry.Rows.Count > 0)
                {
                    DataRow[] rowPsgrAry = dtPsgrAry.Select("psgrBreakUp_Id=" + psgrBreakUp_Id);
                    psgrAy_id = rowPsgrAry[0]["psgrAry_Id"].ToString();

                }
                DataTable dtPsgr = dsIntFlights.Tables[17];
                if (dtPsgr.Rows.Count > 0)
                {
                    DataRow[] rowPsgr = dtPsgr.Select("psgrAry_Id=" + psgrAy_id);
                    FarePsgrType = rowPsgr[0]["psgrType"].ToString();
                    FareBaseFare = rowPsgr[0]["BaseFare"].ToString();
                    FareTax1 = rowPsgr[0]["Tax"].ToString();
                    BagInfo = rowPsgr[0]["BagInfo"].ToString();
                    //child
                    //CFarePsgrType = rowPsgr[1]["psgrType"].ToString();
                    //CFareBaseFare = rowPsgr[1]["BaseFare"].ToString();
                    //CFareTax1 = rowPsgr[1]["Tax"].ToString();
                    //CBagInfo = rowPsgr[1]["BagInfo"].ToString();
                    ////infant
                    //IFarePsgrType = rowPsgr[2]["psgrType"].ToString();
                    //IFareBaseFare = rowPsgr[2]["BaseFare"].ToString();
                    //IFareTax1 = rowPsgr[2]["Tax"].ToString();
                    //IBagInfo = rowPsgr[2]["BagInfo"].ToString();

                }

                if (dtPsgr.Rows.Count > 0)
                {
                    DataRow[] rowPsgr = dtPsgr.Select("psgrAry_Id=" + psgrAy_id);
                    foreach (DataRow rows in rowPsgr)
                    {
                        if (rows.Table.Rows.Count == 0)
                        {
                            taxdatapsgr = "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo></BagInfo></Psgr>";
                        }
                        else
                        {
                            taxdatapsgr = taxdatapsgr + "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo></BagInfo></Psgr>";
                        }
                    }
                }
            }
            //  <Psgr><PsgrType>" + FarePsgrType + "</PsgrType><BaseFare>" + FareBaseFare + "</BaseFare><Tax>" + FareTax1 + "</Tax><BagInfo></BagInfo></Psgr>
            DataTable dtTaxDataAry = dsIntFlights.Tables[8];
            if (dtTaxDataAry.Rows.Count > 0)
            {
                DataRow[] rowTaxDataAry = dtTaxDataAry.Select("Fare_id=" + FareId);
                taxDataAry_id = rowTaxDataAry[0]["TaxdataAry_Id"].ToString();
            }
            DataTable dtTaxData = dsIntFlights.Tables[9];
            if (dtTaxData.Rows.Count > 0)
            {
                DataRow[] rowTaxData = dtTaxData.Select("TaxdataAry_Id=" + taxDataAry_id);
                for (int j = 0; j < rowTaxData.Length; j++)
                {
                    if (rowTaxData.Length == 0)
                    {
                        taxData = "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";

                    }
                    else
                    {
                        taxData = taxData + "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";
                        //ravi
                        //  taxData = taxData + "<Fare><PsgrType>" + dtFare.Rows[j]["PsgrType"].ToString() + "</PsgrType><BaseFare>" + dtFare.Rows[j]["BaseFare"].ToString() + "</BaseFare><Tax>" + dtFare.Rows[j]["Tax"].ToString() + "</Tax><TaxDataAry><TaxData><Country>" + rowTaxData[0]["Country"].ToString() + "</Country><Amt>" + rowTaxData[0]["Amt"].ToString() + "</Amt></TaxData><TaxData><Country>" + rowTaxData[1]["Country"].ToString() + "</Country><Amt>" + rowTaxData[1]["Amt"].ToString() + "</Amt></TaxData><TaxData><Country>" + rowTaxData[2]["Country"].ToString() + "</Country><Amt>" + rowTaxData[2]["Amt"].ToString() + "</Amt></TaxData></TaxDataAry></Fare>";

                    }
                }

            }
            if (dtFare.Rows.Count > 0)
            {
                DataRow[] rowFare = dtFare.Select("FareAry_id=" + FareAry_id);
                foreach (DataRow row in rowFare)
                {
                    if (row.Table.Rows.Count == 0)
                    {
                        str = "<Fare><PsgrType>" + row["PsgrType"].ToString() + "</PsgrType><BaseFare>" + row["BaseFare"].ToString() + "</BaseFare><Tax>" + row["Tax"].ToString() + "</Tax><TaxDataAry>" + taxData + "</TaxDataAry></Fare>";
                    }
                    else
                    {
                        str = str + "<Fare><PsgrType>" + row["PsgrType"].ToString() + "</PsgrType><BaseFare>" + row["BaseFare"].ToString() + "</BaseFare><Tax>" + row["Tax"].ToString() + "</Tax><TaxDataAry>" + taxData + "</TaxDataAry></Fare>";
                    }
                }
            }

            bool res1 = false;

            if (Session["Role"].ToString() == "User")
            {

                //ravi db save

                FlightBAL objFlightBal = new FlightBAL();
                String RefNo = Common.GetFlightsReferenceNo("LJIF");
                Session["Order_Id"] = RefNo.ToString();
                objFlightBal.ReferenceNo = RefNo.ToString();
                objFlightBal.TransId = "0";
                objFlightBal.Status = "Pending";
                objFlightBal.AdultPax = Convert.ToInt32(Session["adultCntInt"]);
                objFlightBal.InfantPax = Convert.ToInt32(Session["infantCntInt"]);
                objFlightBal.ChildPax = Convert.ToInt32(Session["childCntInt"]);
                objFlightBal.Origin_Destination_Id = id;
                objFlightBal.Origin_Destination_Key = key;
                objFlightBal.ActualBasefare = Convert.ToDecimal(ActualBaseFare);
                objFlightBal.Tax = Convert.ToDecimal(Tax);
                objFlightBal.STax = Convert.ToDecimal(STax);
                objFlightBal.TCharge = Convert.ToDecimal(TCharge);
                objFlightBal.Scharge = Convert.ToDecimal(SCharge);
                objFlightBal.TDiscount = Convert.ToDecimal(TDiscount);
                objFlightBal.TMarkUp = Convert.ToDecimal(TMarkup);
                objFlightBal.TPartnerCommission = Convert.ToDecimal(TPartnerCommission);
                objFlightBal.TSDiscount = Convert.ToDecimal(TSdiscount);
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                objFlightBal.TripMode = "One";
                objFlightBal.ocTax = ocTax;
                objFlightBal.Return = return1;
                objFlightBal.id = id;
                objFlightBal.key = key;

                DataTable dtflightBookingId = objFlightBal.AddDInternationalFlightBooking(objFlightBal);
                Session["BookingID"] = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();

                //fegments

                string customerInfo = string.Empty;
                Table tbladults = (Table)this.UpdatePanel2.FindControl("tblAdultsInt");
                for (int l = 1; l <= Convert.ToInt32(Session["adultCntInt"]); l++)
                {

                    TextBox txtFn = (TextBox)tbladults.FindControl("txtFnInt" + l);
                    TextBox txtLn = (TextBox)tbladults.FindControl("txtLnInt" + l);
                    DropDownList ddlTitle = (DropDownList)tbladults.FindControl("ddlTitleInt" + l);

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
                }

                Table tblChild = (Table)this.UpdatePanel2.FindControl("tblChildInt");
                for (int j = 1; j <= Convert.ToInt32(Session["childCntInt"]); j++)
                {
                    TextBox txtFn = (TextBox)tblChild.FindControl("txtCFnInt" + j);

                    TextBox txtLn = (TextBox)tblChild.FindControl("txtCLnInt" + j);

                    DropDownList ddlTitle = (DropDownList)tblChild.FindControl("ddlCTitleInt" + j);

                    TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDateInt" + j);

                    string age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
                }

                Table tblInfants = (Table)this.UpdatePanel2.FindControl("tblInfantsInt");
                for (int k = 1; k <= Convert.ToInt32(Session["infantCntInt"]); k++)
                {
                    TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFnInt" + k);

                    TextBox txtLn = (TextBox)tblInfants.FindControl("txtILnInt" + k);

                    DropDownList ddlTitle = (DropDownList)tblInfants.FindControl("ddlITitleInt" + k);

                    TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDateInt" + k);
                    string age = string.Empty;
                    if (txtBirthDate != null)
                        age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                    else
                        age = "0";

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>inf</psgrtype></CustomerInfo>";
                }

                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int j = 0; j < rowFilghtSegment.Length; j++)
                    {
                        AirEquipType = rowFilghtSegment[j]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFilghtSegment[j]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFilghtSegment[j]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFilghtSegment[j]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFilghtSegment[j]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFilghtSegment[j]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFilghtSegment[j]["DepartureDateTime"].ToString();
                        FlightNumber = rowFilghtSegment[j]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFilghtSegment[j]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFilghtSegment[j]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFilghtSegment[j]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFilghtSegment[j]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFilghtSegment[j]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFilghtSegment[j]["LinkSellAgrmnt"].ToString();
                        Conx = rowFilghtSegment[j]["Conx"].ToString();
                        AirpChg = rowFilghtSegment[j]["AirpChg"].ToString();
                        InsideAvailOption = rowFilghtSegment[j]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFilghtSegment[j]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFilghtSegment[j]["DaysOperates"].ToString();
                        JrnyTm = rowFilghtSegment[j]["JrnyTm"].ToString();
                        EndDt = rowFilghtSegment[j]["EndDt"].ToString();
                        StartTerminal = rowFilghtSegment[j]["StartTerminal"].ToString();
                        EndTerminal = rowFilghtSegment[j]["EndTerminal"].ToString();
                        FltTm = rowFilghtSegment[j]["FltTm"].ToString();
                        LSAInd = rowFilghtSegment[j]["LSAInd"].ToString();
                        Mile = rowFilghtSegment[j]["Mile"].ToString();

                        DataTable dtBookingClass1 = dsIntFlights.Tables[13];
                        if (dtBookingClass1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtBookingClass1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        DataTable dtBookingClassFare1 = dsIntFlights.Tables[14];
                        if (dtBookingClassFare1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtBookingClassFare1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();

                        }
                        //   bookingclass = rowFilghtSegment[j]["LSAInd"].ToString();
                        //   classType = rowFilghtSegment[j]["Mile"].ToString();

                        objFlightBal.FlightBookingID = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();//Convert.ToString(Session["BookingID"]);
                        objFlightBal.AirEquipType = AirEquipType;
                        objFlightBal.ArrivalAirportCode = ArrivalAirportCode;
                        objFlightBal.ArrivalAirportName = ArrivalAirportName;
                        objFlightBal.ArrivalDateTime = ArrivalDateTime;
                        objFlightBal.DepartureAirportCode = DepartureAirportCode;
                        objFlightBal.DepartureAirportName = DepartureAirportName;
                        objFlightBal.DepartureDateTime = DepartureDateTime;
                        objFlightBal.FlightNumber = FlightNumber;
                        objFlightBal.MarketingAirlineCode = MarketingAirlineCode;
                        objFlightBal.OperatingAirlineCode = OperatingAirlineCode;
                        objFlightBal.OperatingAirlineName = OperatingAirlineName;
                        objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumber;
                        objFlightBal.NumStops = NumStops;
                        objFlightBal.LinkSellAgrmnt = LinkSellAgrmnt;
                        objFlightBal.Conx = Conx;
                        objFlightBal.AirpChg = AirpChg;
                        objFlightBal.InsideAvailOption = InsideAvailOption;
                        objFlightBal.GenTrafRestriction = GenTrafRestriction;
                        objFlightBal.DaysOperates = DaysOperates;
                        objFlightBal.JrnyTm = JrnyTm;
                        objFlightBal.EndDt = EndDt;
                        objFlightBal.StartTerminal = StartTerminal;
                        objFlightBal.EndTerminal = EndTerminal;
                        objFlightBal.FltTm = FltTm;
                        objFlightBal.LSAInd = LSAInd;
                        objFlightBal.Mile = Mile;
                        objFlightBal.Availability = Availability;
                        objFlightBal.BIC = BIC;
                        objFlightBal.emailAddress = txtEmailIDInt.Text.Trim();
                        Session["EmailID"] = txtEmailIDInt.Text.Trim();
                        objFlightBal.telephone = txtMobileNumberInt.Text;
                        Session["MobileNo"] = txtMobileNumberInt.Text;
                        objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                        objFlightBal.Customer_Details = customerInfo;
                        objFlightBal.Address = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        Session["customerInfo"] = customerInfo;
                        Session["Address"] = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        objFlightBal.bookingClass = bookingclass;
                        objFlightBal.ClassType = classType;
                        objFlightBal.farebasisCode = farebasiscode;
                        objFlightBal.Fare_Rule = Rule;
                        objFlightBal.PsgrType = FarePsgrType;
                        objFlightBal.BaseFare = FareBaseFare;
                        objFlightBal.psgrTax = FareTax1;
                        objFlightBal.BagInfo = BagInfo;
                        objFlightBal.FarePsgrType = faretype;

                        res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);

                    }
                }

                if (res1 == true)
                {
                    Response.Redirect("~/pay.aspx?val=true", false);
                }
                //db save end
            }
            else
            {

                FlightBAL objFlightsBal = new FlightBAL();

                #region Pricing
                //  string XmlPricingRequest = "<PriceRequest><noadults>" + ddlAdultsInt.SelectedValue + "</noadults><nochild>" + ddlChildsInt.SelectedValue + "</nochild><noinfant>" + ddlInfantsInt.SelectedValue + "</noinfant><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooINTLWS1.0</Clienttype><OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry><Fare><PsgrType>" + PsgrType + "</PsgrType><BaseFare>" + BaseFare + "</BaseFare><Tax>" + FareTax + "</Tax></Fare></FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails>";
                string XmlPricingRequest = "<PriceRequest><noadults>" + ddlAdultsInt.SelectedValue + "</noadults><nochild>" + ddlChildsInt.SelectedValue + "</nochild><noinfant>" + ddlInfantsInt.SelectedValue + "</noinfant><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooINTLWS1.0</Clienttype><OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry>" + str + "</FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails>";
                XmlPricingRequest = XmlPricingRequest + "<onward><FlightSegments>";

                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int j = 0; j < rowFilghtSegment.Length; j++)
                    {
                        AirEquipType = rowFilghtSegment[j]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFilghtSegment[j]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFilghtSegment[j]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFilghtSegment[j]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFilghtSegment[j]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFilghtSegment[j]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFilghtSegment[j]["DepartureDateTime"].ToString();
                        FlightNumber = rowFilghtSegment[j]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFilghtSegment[j]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFilghtSegment[j]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFilghtSegment[j]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFilghtSegment[j]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFilghtSegment[j]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFilghtSegment[j]["LinkSellAgrmnt"].ToString();
                        Conx = rowFilghtSegment[j]["Conx"].ToString();
                        AirpChg = rowFilghtSegment[j]["AirpChg"].ToString();
                        InsideAvailOption = rowFilghtSegment[j]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFilghtSegment[j]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFilghtSegment[j]["DaysOperates"].ToString();
                        JrnyTm = rowFilghtSegment[j]["JrnyTm"].ToString();
                        EndDt = rowFilghtSegment[j]["EndDt"].ToString();
                        StartTerminal = rowFilghtSegment[j]["StartTerminal"].ToString();
                        EndTerminal = rowFilghtSegment[j]["EndTerminal"].ToString();
                        FltTm = rowFilghtSegment[j]["FltTm"].ToString();
                        LSAInd = rowFilghtSegment[j]["LSAInd"].ToString();
                        Mile = rowFilghtSegment[j]["Mile"].ToString();

                        DataTable dtBookingClass1 = dsIntFlights.Tables[13];
                        if (dtBookingClass1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtBookingClass1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        DataTable dtBookingClassFare1 = dsIntFlights.Tables[14];
                        if (dtBookingClassFare1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtBookingClassFare1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();

                        }

                        XmlPricingRequest = XmlPricingRequest + "<FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportName + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportName + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber>";
                        XmlPricingRequest = XmlPricingRequest + "<MarketingAirlineCode>" + MarketingAirlineCode + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineName + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><NumStops>" + NumStops + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmnt + "</LinkSellAgrmnt><Conx>" + Conx + "</Conx><AirpChg>" + AirpChg + "</AirpChg><InsideAvailOption>" + InsideAvailOption + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestriction + "</GenTrafRestriction><DaysOperates>" + DaysOperates + "</DaysOperates><JrnyTm>" + JrnyTm + "</JrnyTm><EndDt>" + EndDt + "</EndDt><StartTerminal>" + StartTerminal + "</StartTerminal><EndTerminal>" + EndTerminal + "</EndTerminal>";
                        // XmlPricingRequest = XmlPricingRequest + "<FltTm>" + FltTm + "</FltTm><LSAInd>" + LSAInd + "</LSAInd><Mile>" + Mile + "</Mile><BookingClass><Availability>" + Availability + "</Availability><BIC>" + BIC + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclass + "</bookingclass><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><Rule>" + Rule.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>" + FarePsgrType + "</PsgrType><BaseFare>" + FareBaseFare + "</BaseFare><Tax>" + FareTax1 + "</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment>";
                        XmlPricingRequest = XmlPricingRequest + "<FltTm>" + FltTm + "</FltTm><LSAInd>" + LSAInd + "</LSAInd><Mile>" + Mile + "</Mile><BookingClass><Availability>" + Availability + "</Availability><BIC>" + BIC + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclass + "</bookingclass><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><Rule>" + Rule.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            XmlPricingRequest = XmlPricingRequest + "<PsgrBreakup><PsgrAry>" + taxdatapsgr + "</PsgrAry></PsgrBreakup>";
                        }
                        XmlPricingRequest = XmlPricingRequest + "</BookingClassFare></FlightSegment>";
                    }
                }
                XmlPricingRequest = XmlPricingRequest + "</FlightSegments></onward><Return>" + return1 + "</Return><id>" + id + "</id><key>" + key + "</key>";
                XmlPricingRequest = XmlPricingRequest + "</OriginDestinationOption></PriceRequest>";

                DataSet dsPricingResponse = objFlightsBal.GetDatasetFromAPI(XmlPricingRequest, "http://live.arzoo.com:9302/Pricing");

                if (dsPricingResponse.Tables[0].Rows[0]["error"] == string.Empty)
                {
                    //  DataTable dtpricingflightsegment = dsPricingResponse.Tables

                    DataTable dtpricingFlightSegment = dsPricingResponse.Tables["FlightSegment"];
                    if (dtpricingFlightSegment.Rows.Count > 0)
                    {
                        DataRow[] rowFilghtSegment = dtpricingFlightSegment.Select("FlightSegment_ID=" + Convert.ToInt32(lblIntFlightSegmentId.Text));
                        FlightSegmentsID = rowFilghtSegment[0]["FlightSegments_Id"].ToString();

                    }
                    DataTable dtpricingFlightSegments = dsPricingResponse.Tables["FlightSegments"];
                    if (dtpricingFlightSegments.Rows.Count > 0)
                    {
                        DataRow[] rowFilghtSegments = dtpricingFlightSegments.Select("FlightSegments_ID=" + FlightSegmentsID);
                        onwardId = rowFilghtSegments[0]["Onward_Id"].ToString();
                    }
                    DataTable dtpricingOnward = dsPricingResponse.Tables["onward"];
                    if (dtpricingOnward.Rows.Count > 0)
                    {
                        DataRow[] rowOnward = dtpricingOnward.Select("Onward_Id=" + onwardId);
                        OriginDestinationOption_Id = rowOnward[0]["OriginDestinationOption_Id"].ToString();
                    }
                    DataTable dtpricingFareDetails = dsIntFlights.Tables["FareDetails"];
                    if (dtFareDetails.Rows.Count > 0)
                    {
                        DataRow[] rowFareDetails = dtFareDetails.Select("OriginDestinationOption_Id=" + OriginDestinationOption_Id);
                        ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                        Tax = rowFareDetails[0]["Tax"].ToString();
                        STax = rowFareDetails[0]["STax"].ToString();
                        TCharge = rowFareDetails[0]["TCharge"].ToString();
                        SCharge = rowFareDetails[0]["SCharge"].ToString();
                        TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                        TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                        TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                        TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                        ocTax = rowFareDetails[0]["ocTax"].ToString();
                        FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
                    }
                }

                #endregion

                string ref1 = Common.GetFlightsReferenceNo("LJIF");

                string xmlRequest = "<Bookingrequest><noadults>" + ddlAdultsInt.SelectedValue + "</noadults><nochild>" + ddlChildsInt.SelectedValue + "</nochild><noinfant>" + ddlInfantsInt.SelectedValue + "</noinfant><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooINTLWS1.0</Clienttype><creditcardno></creditcardno><PartnerreferenceID>" + ref1 + "</PartnerreferenceID>";
                xmlRequest = xmlRequest + "<personName>";

                // Dynamic generation of names of adults, infants , Child
                Table tbladults = (Table)this.UpdatePanel2.FindControl("tblAdultsInt");
                for (int i = 1; i <= Convert.ToInt32(Session["adultCntInt"]); i++)
                {

                    TextBox txtFn = (TextBox)tbladults.FindControl("txtFnInt" + i);
                    TextBox txtLn = (TextBox)tbladults.FindControl("txtLnInt" + i);
                    DropDownList ddlTitle = (DropDownList)tbladults.FindControl("ddlTitleInt" + i);

                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
                }

                Table tblChild = (Table)this.UpdatePanel2.FindControl("tblChildInt");
                for (int i = 1; i <= Convert.ToInt32(Session["childCntInt"]); i++)
                {
                    TextBox txtFn = (TextBox)tblChild.FindControl("txtCFnInt" + i);

                    TextBox txtLn = (TextBox)tblChild.FindControl("txtCLnInt" + i);

                    DropDownList ddlTitle = (DropDownList)tblChild.FindControl("ddlCTitleInt" + i);

                    TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDateInt" + i);

                    string age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                    //if (Convert.ToInt32(age) > 5)
                    //{
                    //    Literal lit = new Literal();
                    //    lit.Text = txtFn.Text + " Age  between 3 - 5 yrs.";
                    //    this.Controls.Add(lit);
                    //    break;
                    //}

                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
                }

                Table tblInfants = (Table)this.UpdatePanel2.FindControl("tblInfantsInt");
                for (int i = 1; i <= Convert.ToInt32(Session["infantCntInt"]); i++)
                {
                    TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFnInt" + i);

                    TextBox txtLn = (TextBox)tblInfants.FindControl("txtILnInt" + i);

                    DropDownList ddlTitle = (DropDownList)tblInfants.FindControl("ddlITitleInt" + i);

                    TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDateInt" + i);
                    string age = string.Empty;
                    if (txtBirthDate != null)
                        age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                    else
                        age = "0";
                    //if (Convert.ToInt32(age) == 12)
                    //{
                    //    Literal lit = new Literal();
                    //    lit.Text = txtFn.Text + " Age should be below 1 yr.";
                    //    this.Controls.Add(lit);
                    //    break;
                    //}

                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>inf</psgrtype></CustomerInfo>";
                }

                xmlRequest = xmlRequest + "</personName><telePhone><phoneNumber>" + txtMobileNumInt.Text + "</phoneNumber></telePhone><email><emailAddress>" + txtEmailIDInt.Text + "</emailAddress></email>";
                //xmlRequest = xmlRequest + "<OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry><Fare><PsgrType>" + PsgrType + "</PsgrType><BaseFare>" + BaseFare + "</BaseFare><Tax>" + FareTax + "</Tax><TaxDataAry>";
                //xmlRequest = xmlRequest + taxData + "</TaxDataAry></Fare></FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails><onward><FlightSegments>";
                xmlRequest = xmlRequest + "<OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry>";
                xmlRequest = xmlRequest + str + "</FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails><onward><FlightSegments>";

                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int j = 0; j < rowFilghtSegment.Length; j++)
                    {
                        AirEquipType = rowFilghtSegment[j]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFilghtSegment[j]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFilghtSegment[j]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFilghtSegment[j]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFilghtSegment[j]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFilghtSegment[j]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFilghtSegment[j]["DepartureDateTime"].ToString();
                        FlightNumber = rowFilghtSegment[j]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFilghtSegment[j]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFilghtSegment[j]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFilghtSegment[j]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFilghtSegment[j]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFilghtSegment[j]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFilghtSegment[j]["LinkSellAgrmnt"].ToString();
                        Conx = rowFilghtSegment[j]["Conx"].ToString();
                        AirpChg = rowFilghtSegment[j]["AirpChg"].ToString();
                        InsideAvailOption = rowFilghtSegment[j]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFilghtSegment[j]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFilghtSegment[j]["DaysOperates"].ToString();
                        JrnyTm = rowFilghtSegment[j]["JrnyTm"].ToString();
                        EndDt = rowFilghtSegment[j]["EndDt"].ToString();
                        StartTerminal = rowFilghtSegment[j]["StartTerminal"].ToString();
                        EndTerminal = rowFilghtSegment[j]["EndTerminal"].ToString();
                        FltTm = rowFilghtSegment[j]["FltTm"].ToString();
                        LSAInd = rowFilghtSegment[j]["LSAInd"].ToString();
                        Mile = rowFilghtSegment[j]["Mile"].ToString();

                        DataTable dtBookingClass1 = dsIntFlights.Tables[13];
                        if (dtBookingClass1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtBookingClass1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        DataTable dtBookingClassFare1 = dsIntFlights.Tables[14];
                        if (dtBookingClassFare1.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtBookingClassFare1.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();

                        }

                        xmlRequest = xmlRequest + "<FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportName + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportName + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber>";
                        xmlRequest = xmlRequest + "<MarketingAirlineCode>" + MarketingAirlineCode + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineName + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><NumStops>" + NumStops + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmnt + "</LinkSellAgrmnt><Conx>" + Conx + "</Conx><AirpChg>" + AirpChg + "</AirpChg><InsideAvailOption>" + InsideAvailOption + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestriction + "</GenTrafRestriction><DaysOperates>" + DaysOperates + "</DaysOperates><JrnyTm>" + JrnyTm + "</JrnyTm><EndDt>" + EndDt + "</EndDt><StartTerminal>" + StartTerminal + "</StartTerminal><EndTerminal>" + EndTerminal + "</EndTerminal>";
                        xmlRequest = xmlRequest + "<FltTm>" + FltTm + "</FltTm><LSAInd>" + LSAInd + "</LSAInd><Mile>" + Mile + "</Mile><BookingClass><Availability>" + Availability + "</Availability><BIC>" + BIC + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclass + "</bookingclass><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><Rule>" + Rule.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            xmlRequest = xmlRequest + "<PsgrBreakup><PsgrAry><Psgr><PsgrType>" + FarePsgrType + "</PsgrType><BaseFare>" + FareBaseFare + "</BaseFare><Tax>" + FareTax1 + "</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup>";
                        }
                        xmlRequest = xmlRequest + "</BookingClassFare></FlightSegment>";
                    }
                }
                xmlRequest = xmlRequest + "</FlightSegments></onward><Return>" + return1 + "</Return><id>" + id + "</id><key>" + key + "</key>";
                xmlRequest = xmlRequest + "</OriginDestinationOption></Bookingrequest>";

                StringBuilder stt = new StringBuilder();

                stt.Append("xmlRequest");
                stt.Append("=");
                stt.Append(Server.UrlEncode(xmlRequest));
                // stt.Append((xmlRequest).Replace("+", "%2B"));

                byte[] requestData = Encoding.UTF8.GetBytes(stt.ToString());

                //byte[] requestData = System.Text.Encoding.UTF8.GetBytes(xmlRequest.Replace("+","%2B"));

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://live.arzoo.com:9302/Booking");

                //request.Accept = @"text/plain,application/xml";
                //request.ContentType = @"application/xml";
                //request.Method = @"POST";
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.Accept = "application/json";
                // request.Accept = "en-us,en;q=0.5";

                //request.ContentType = "multipart/form-data";
                request.ContentLength = requestData.Length;

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(requestData, 0, requestData.Length);
                }
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (Stream stream = response.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
                            result = reader.ReadToEnd();
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(result);
                        XmlNodeReader xmlReader = new XmlNodeReader(doc);

                        ds.ReadXml(xmlReader);
                    }
                }

                //result = "<Bookingresponse><OriginDestinationOption><FareDetails><ActualBaseFare>85035</ActualBaseFare><Tax>4079</Tax><STax>1055</STax><TCharge>0</TCharge><SCharge>0</SCharge><TDiscount>0</TDiscount><TMarkup>150</TMarkup><TPartnerCommission>0</TPartnerCommission><TSdiscount>0</TSdiscount><FareBreakup><FareAry><Fare><PsgrType>ADT</PsgrType><BaseFare>85035</BaseFare><Tax>4079</Tax></Fare></FareAry></FareBreakup></FareDetails><onward><FlightSegments><FlightSegment><AirEquipType>77W</AirEquipType><ArrivalAirportCode>LHR</ArrivalAirportCode><ArrivalAirportName>LONDON&lt;BR&gt; (HEATHROW)</ArrivalAirportName><ArrivalDateTime>2010-02-26T06:35:00</ArrivalDateTime><DepartureAirportCode>BOM</DepartureAirportCode><DepartureAirportName>MUMBAI&lt;BR&gt; (CHHATRAPATI SHIVAJI INTERNATIONAL)</DepartureAirportName><DepartureDateTime>2010-02-26T02:05:00</DepartureDateTime><FlightNumber>4131</FlightNumber><MarketingAirlineCode>BD</MarketingAirlineCode><OperatingAirlineCode>BD</OperatingAirlineCode><OperatingAirlineName>British Midland</OperatingAirlineName><OperatingAirlineFlightNumber>4131</OperatingAirlineFlightNumber><NumStops>0</NumStops><LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>9</Availability><BIC>Y</BIC></BookingClass><BookingClassFare><bookingclass>Y</bookingclass><classType>Economy</classType><farebasiscode>rb8QAsvpFIPpZo9gBUBg+6BMOP0MtJ7L</farebasiscode><Rule></Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>85035</BaseFare><Tax>4079</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment><FlightSegment><AirEquipType>346</AirEquipType><ArrivalAirportCode>JFK</ArrivalAirportCode><ArrivalAirportName>NEW YORK&lt;BR&gt; (JOHN F KENNEDY INTL)</ArrivalAirportName><ArrivalDateTime>2010-02-26T12:20:00</ArrivalDateTime><DepartureAirportCode>LHR</DepartureAirportCode><DepartureAirportName>LONDON&lt;BR&gt; (HEATHROW)</DepartureAirportName><DepartureDateTime>2010-02-26T09:20:00</DepartureDateTime><FlightNumber>8223</FlightNumber><MarketingAirlineCode>CO</MarketingAirlineCode><OperatingAirlineCode>CO</OperatingAirlineCode><OperatingAirlineName>Continental Airlines </OperatingAirlineName><OperatingAirlineFlightNumber>8223</OperatingAirlineFlightNumber><NumStops>0</NumStops><LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>4</Availability><BIC>L</BIC></BookingClass><BookingClassFare><bookingclass>L</bookingclass><classType>Economy</classType><farebasiscode>rb8QAsvpFIPpZo9gBUBg+6BMOP0MtJ7L</farebasiscode><Rule></Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>85035</BaseFare><Tax>4079</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment></FlightSegments></onward><Return/><id>arzoo100</id><key>ayCbutV8CZjQweTiPhdGIT52/cnXSmDtWDF6uoVa0Yx+dIrODcZqUYV1i7vZuywrXxtmsFOjbi9n4urlPHf4zxGFVKSEVPuglBZfw/aOkGOFdYu72bssKyww8nhfPbQTtwJT+FL3EYT6Z0r5IgK9i8O9cVe5sN0jK6gQR/0VsA3jPu65QFu4leESvkw2tYVo0MHk4j4XRiFoKIn0f2tgo+sVQZmUH8fjjct7YYgqWIoUUZ48kBq4e/0pg3DmQVVVo2Q3a0AUQSXLUP1Wu6PBd4V1i7vZuywrSdRter3iPenjPu65QFu4lbsv+JV45WPGtyljvg7883Sh2gnY0OmCJCn868u75ToLhXWLu9m7LCuMmusGneSEdRuxNaSOsudhnGqNtXQ916PjPu65QFu4lU2r9RVG+D9a0MHk4j4XRiFoKIn0f2tgozK2rkfhSWEWx6xZaH0ssx82RPW27flqmu5f2a5HBe02z/lJy0jWbT0M1G6o3Y+hzWfi6uU8d/jPAJdXKqYIvc5G93zQPY0iVQD8L1fsyfdm6xVBmZQfx+ONy3thiCpYihlAiI3xsTJF4z7uuUBbuJUEGsOfbTr3UF/rxHYOApxUsDfYCka6IQumFoD34DG1PbcCU/hS9xGEMwKsr63khSb3Qspj6nxBZe9bfmEZ7GUgEriX6+12U2wkVz4JY1XabcCU/hS9xGEcUGtscRHmuLDvXFXubDdIz12g5QheQXO4z7uuUBbuJVmadCAqLb2y2fi6uU8d/jPS1i6Qoti3wtoJoL9ZE4l6rEu1ZiKp4vJfk8fwf1jcc9f68R2DgKcVK1lGTAnSPxSl9HJUgz+eC+FdYu72bssKzNAqSxshbWRYUz9VFYzmixqeExNPowVA78GaMTl9BYe0fUDu2DE3rHDvXFXubDdI3dYiTg2zkNgU+gGkoFGtlfAPC2FpjoIsV/rxHYOApxURZOpRI/EzoEVg7MnTiMjPoV1i7vZuywrp7AOSJb8tei2GAYztr4tGO6Udvv6goYtX+vEdg4CnFThuwJPu5BuYitpzzDzl21bJ/v5/y98kwILsR2pjhA21YV1i7vZuywrGJgEwhHzH+9n4urlPHf4zwMsIQITsGsy0MHk4j4XRiFoKIn0f2tgowznwUkbWS71w71xV7mw3SOi9DZLo5De59CaB/YiXgfO40U/DdrAcfnP5jcg4z9RPIZB8/lb/sd5w71xV7mw3SNZoQyFRfkMl+M+7rlAW7iVOm7uM/9yhhNn4urlPHf4z7kR+x0lYQ5LX+vEdg4CnFRKt+2PZYo+CjOuGPE4fK4oZ+Lq5Tx3+M9KeFGbag7+buM+7rlAW7iVdKLgjh+EGg8Mv3JUr8Yz2NNESEN0N1nFqHicn8G1rgW8dJypOMfNAYV1i7vZuywrLDDyeF89tBO3AlP4UvcRhPpnSvkiAr2L00RIQ3Q3WcWoeJyfwbWuBfSvd+pfPzkTw71xV7mw3SNdcG/zHitfN1rAgZFeAikBjct7YYgqWIpXyYBKr/eg5uM+7rlAW7iVygQsiztYTQ9f68R2DgKcVBCq+RQJHE/z</key></OriginDestinationOption><telePhone><phoneNumber>9879961339</phoneNumber></telePhone><email><emailAddress>[email protected]</emailAddress></email><noadults>1</noadults><nochild>0</nochild><noinfant>0</noinfant><Clientid>Given By Arzoo.com</Clientid><Clienttype>ArzooINTLWS1.0</Clienttype><creditcardno>1234567890123456</creditcardno><error></error><personName><CustomerInfo><givenName>Sagar</givenName><surName>Arora</surName><nameReference>Mr.</nameReference><psgrtype>adt</psgrtype></CustomerInfo></personName><status>SUCCESS</status><transid>A396009</transid></Bookingresponse>";

                //   XmlDocument doc = new XmlDocument();
                //   doc.LoadXml(result);
                //   XmlNodeReader xmlReader = new XmlNodeReader(doc);

                //   ds.ReadXml(xmlReader);

            }
        }

        catch (Exception ex)
        {
            if (ex.Message.Contains("409"))
            {
                lblerror.Text = "Please contact administrator";
                lblerror.Visible = true;
            }
        }
        return ds;
    }
    private DataSet GetRoundtripIntBookingRequest()
    {
        DataSet dsResponse = new DataSet();
        dsIntFlights = (DataSet)Session["dsIntFlights"];
        string result = string.Empty;
        try
        {
            #region Variables
            string faretype = string.Empty;
            string str = string.Empty;
            string FlightSegmentsID = string.Empty;
            string DepartureAirportCode = string.Empty;
            string ArrivalDateTime = string.Empty;
            string DepartureAirportName = string.Empty;
            string DepartureDateTime = string.Empty;
            string FlightNumber = string.Empty;
            string MarketingAirlineCode = string.Empty;
            string OperatingAirlineCode = string.Empty;
            string OperatingAirlineName = string.Empty;
            string OperatingAirlineFlightNumber = string.Empty;
            string NumStops = string.Empty;
            string LinkSellAgrmnt = string.Empty;
            string Conx = string.Empty;
            string AirpChg = string.Empty;
            string InsideAvailOption = string.Empty;
            string GenTrafRestriction = string.Empty;
            string DaysOperates = string.Empty;
            string JrnyTm = string.Empty;
            string EndDt = string.Empty;
            string StartTerminal = string.Empty;
            string EndTerminal = string.Empty;
            string FltTm = string.Empty;
            string LSAInd = string.Empty;
            string Mile = string.Empty;
            string Availability = string.Empty;
            string BIC = string.Empty;
            string bookingclass = string.Empty;
            string classType = string.Empty;
            string farebasiscode = string.Empty;
            string Rule = string.Empty;
            string PsgrType = string.Empty;
            string BaseFare = string.Empty;
            string Tax = string.Empty;
            string BagInfo = string.Empty;
            string AirEquipType = string.Empty;
            string ArrivalAirportCode = string.Empty;
            string ArrivalAirportName = string.Empty;
            string return1 = string.Empty;
            string id = string.Empty;
            string key = string.Empty;
            string ActualBaseFare = string.Empty;
            string FareTax = string.Empty;
            string STax = string.Empty;
            string TCharge = string.Empty;
            string SCharge = string.Empty;
            string TDiscount = string.Empty;
            string TMarkup = string.Empty;
            string TPartnerCommission = string.Empty;
            string TSdiscount = string.Empty;
            string FarePsgrType = string.Empty;
            string FareBaseFare = string.Empty;
            string FareTax1 = string.Empty;
            string Country = string.Empty;
            string Amt = string.Empty;
            string ocTax = string.Empty;
            string onwardId = string.Empty;
            string OriginDestinationOption_Id = string.Empty;
            string FareDetails_id = string.Empty;
            string FareBreakUp_Id = string.Empty;
            string FareAry_id = string.Empty;
            string FareId = string.Empty;
            string bookingclassFareId = string.Empty;
            string psgrBreakUp_Id = string.Empty;
            string psgrAy_id = string.Empty;
            string country = string.Empty;
            string taxAmt = string.Empty;
            string taxData = string.Empty;
            string taxDataAry_id = string.Empty;
            string returnId = string.Empty;

            string FlightSegmentsIDRet = string.Empty;
            string DepartureAirportCodeRet = string.Empty;
            string ArrivalDateTimeRet = string.Empty;
            string DepartureAirportNameRet = string.Empty;
            string DepartureDateTimeRet = string.Empty;
            string FlightNumberRet = string.Empty;
            string MarketingAirlineCodeRet = string.Empty;
            string OperatingAirlineCodeRet = string.Empty;
            string OperatingAirlineNameRet = string.Empty;
            string OperatingAirlineFlightNumberRet = string.Empty;
            string NumStopsRet = string.Empty;
            string LinkSellAgrmntRet = string.Empty;
            string ConxRet = string.Empty;
            string AirpChgRet = string.Empty;
            string InsideAvailOptionRet = string.Empty;
            string GenTrafRestrictionRet = string.Empty;
            string DaysOperatesRet = string.Empty;
            string JrnyTmRet = string.Empty;
            string EndDtRet = string.Empty;
            string StartTerminalRet = string.Empty;
            string EndTerminalRet = string.Empty;
            string FltTmRet = string.Empty;
            string LSAIndRet = string.Empty;
            string MileRet = string.Empty;
            string AvailabilityRet = string.Empty;
            string BICRet = string.Empty;
            string bookingclassRet = string.Empty;
            string classTypeRet = string.Empty;
            string farebasiscodeRet = string.Empty;
            string RuleRet = string.Empty;
            string PsgrTypeRet = string.Empty;
            string BaseFareRet = string.Empty;
            string TaxRet = string.Empty;
            string BagInfoRet = string.Empty;
            string AirEquipTypeRet = string.Empty;
            string ArrivalAirportCodeRet = string.Empty;
            string ArrivalAirportNameRet = string.Empty;

            string idRet = string.Empty;
            string keyRet = string.Empty;
            string ActualBaseFareRet = string.Empty;
            string FareTaxRet = string.Empty;
            string STaxRet = string.Empty;
            string TChargeRet = string.Empty;
            string SChargeRet = string.Empty;
            string TDiscountRet = string.Empty;
            string TMarkupRet = string.Empty;
            string TPartnerCommissionRet = string.Empty;
            string TSdiscountRet = string.Empty;
            string FarePsgrTypeRet = string.Empty;
            string FareBaseFareRet = string.Empty;
            string FareTax1Ret = string.Empty;
            string CountryRet = string.Empty;
            string AmtRet = string.Empty;
            string ocTaxRet = string.Empty;
            string onwardIdRet = string.Empty;
            string OriginDestinationOption_IdRet = string.Empty;
            string FareDetails_idRet = string.Empty;
            string FareBreakUp_IdRet = string.Empty;
            string FareAry_idRet = string.Empty;
            string FareIdRet = string.Empty;
            string bookingclassFareIdRet = string.Empty;
            string psgrBreakUp_IdRet = string.Empty;
            string psgrAy_idRet = string.Empty;
            string countryRet = string.Empty;
            string taxAmtRet = string.Empty;
            string taxDataRet = string.Empty;
            string taxDataAry_idRet = string.Empty;
            string returnIdRet = string.Empty;

            string taxdatapsgr = string.Empty;
            string taxdatapsgrRet = string.Empty;
            #endregion

            #region Pricing

            DataTable dtPricingreqOriginDestinationOption = dsIntFlights.Tables["OriginDestinationOption"];
            if (dtPricingreqOriginDestinationOption.Rows.Count > 0)
            {
                DataRow[] rowOriginDestinationOption = dtPricingreqOriginDestinationOption.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                id = rowOriginDestinationOption[0]["id"].ToString();
                key = rowOriginDestinationOption[0]["key"].ToString();

            }

            //Get Details From roundtrip response
            DataTable dtPricingreqFareDetails = dsIntFlights.Tables["FareDetails"];
            if (dtPricingreqFareDetails.Rows.Count > 0)
            {
                DataRow[] rowFareDetails = dtPricingreqFareDetails.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                Tax = rowFareDetails[0]["Tax"].ToString();
                STax = rowFareDetails[0]["STax"].ToString();
                TCharge = rowFareDetails[0]["TCharge"].ToString();
                SCharge = rowFareDetails[0]["SCharge"].ToString();
                TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                ocTax = rowFareDetails[0]["ocTax"].ToString();
                FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
            }
            DataTable dtPricingreqFareBreakUp = dsIntFlights.Tables["FareBreakUp"];
            if (dtPricingreqFareBreakUp.Rows.Count > 0)
            {
                DataRow[] rowFareBreakUp = dtPricingreqFareBreakUp.Select("FareDetails_Id=" + FareDetails_id);
                FareBreakUp_Id = rowFareBreakUp[0]["FareBreakUp_Id"].ToString();

            }
            DataTable dtPricingreqFareAry = dsIntFlights.Tables["FareAry"];
            if (dtPricingreqFareAry.Rows.Count > 0)
            {
                DataRow[] rowFareAry = dtPricingreqFareAry.Select("FareBreakUp_Id=" + FareBreakUp_Id);
                FareAry_id = rowFareAry[0]["FareAry_id"].ToString();
            }
            DataTable dtPricingreqFare = dsIntFlights.Tables["Fare"];
            if (dtPricingreqFare.Rows.Count > 0)
            {
                DataRow[] rowFare = dtPricingreqFare.Select("FareAry_id=" + FareAry_id);
                PsgrType = rowFare[0]["PsgrType"].ToString();
                BaseFare = rowFare[0]["BaseFare"].ToString();
                FareTax = rowFare[0]["Tax"].ToString();
                FareId = rowFare[0]["Fare_Id"].ToString();
                foreach (DataRow dr in rowFare)
                {
                    if (faretype == "")
                    {
                        faretype = dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString();
                    }
                    else
                    {

                        faretype = faretype + ";" + dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString() + ";";
                    }
                }
            }

            if (dtPricingreqFare.Rows.Count > 0)
            {
                DataRow[] rowFare = dtPricingreqFare.Select("FareAry_id=" + FareAry_id);
                foreach (DataRow row in rowFare)
                {
                    if (row.Table.Rows.Count == 0)
                    {
                        str = "<Fare><PsgrType>" + row["PsgrType"].ToString() + "</PsgrType><BaseFare>" + row["BaseFare"].ToString() + "</BaseFare><Tax>" + row["Tax"].ToString() + "</Tax></Fare>";
                    }
                    else
                    {
                        str = str + "<Fare><PsgrType>" + row["PsgrType"].ToString() + "</PsgrType><BaseFare>" + row["BaseFare"].ToString() + "</BaseFare><Tax>" + row["Tax"].ToString() + "</Tax></Fare>";//<TaxDataAry>" + str + "</TaxDataAry>
                    }
                }
            }

            bool res1 = false;

            if (Session["Role"].ToString() == "User")
            {

                //db save
                FlightBAL objFlightBal = new FlightBAL();
                String RefNo = Common.GetFlightsReferenceNo("LJIF");
                Session["Order_Id"] = RefNo.ToString();
                objFlightBal.ReferenceNo = RefNo.ToString();
                objFlightBal.TransId = "0";
                objFlightBal.Status = "Pending";
                objFlightBal.AdultPax = Convert.ToInt32(Session["adultCntInt"]);
                objFlightBal.InfantPax = Convert.ToInt32(Session["infantCntInt"]);
                objFlightBal.ChildPax = Convert.ToInt32(Session["childCntInt"]);
                objFlightBal.Origin_Destination_Id = id;
                objFlightBal.Origin_Destination_Key = key;
                objFlightBal.ActualBasefare = Convert.ToDecimal(ActualBaseFare);
                objFlightBal.Tax = Convert.ToDecimal(Tax);
                objFlightBal.STax = Convert.ToDecimal(STax);
                objFlightBal.TCharge = Convert.ToDecimal(TCharge);
                objFlightBal.Scharge = Convert.ToDecimal(SCharge);
                objFlightBal.TDiscount = Convert.ToDecimal(TDiscount);
                objFlightBal.TMarkUp = Convert.ToDecimal(TMarkup);
                objFlightBal.TPartnerCommission = Convert.ToDecimal(TPartnerCommission);
                objFlightBal.TSDiscount = Convert.ToDecimal(TSdiscount);
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                objFlightBal.TripMode = "Round";
                objFlightBal.ocTax = ocTax;
                //   objFlightBal.Return = return1;
                objFlightBal.id = id;
                objFlightBal.key = key;

                DataTable dtflightBookingId = objFlightBal.AddDInternationalFlightBooking(objFlightBal);
                Session["BookingID"] = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();

                //fegments

                string customerInfo = string.Empty;
                Table tbladults = (Table)this.UpdatePanel2.FindControl("tblAdultsInt");
                for (int l = 1; l <= Convert.ToInt32(Session["adultCntInt"]); l++)
                {

                    TextBox txtFn = (TextBox)tbladults.FindControl("txtFnInt" + l);
                    TextBox txtLn = (TextBox)tbladults.FindControl("txtLnInt" + l);
                    DropDownList ddlTitle = (DropDownList)tbladults.FindControl("ddlTitleInt" + l);

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
                }

                Table tblChild = (Table)this.UpdatePanel2.FindControl("tblChildInt");
                for (int j = 1; j <= childCntInt; j++)
                {
                    TextBox txtFn = (TextBox)tblChild.FindControl("txtCFnInt" + j);

                    TextBox txtLn = (TextBox)tblChild.FindControl("txtCLnInt" + j);

                    DropDownList ddlTitle = (DropDownList)tblChild.FindControl("ddlCTitleInt" + j);

                    TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDateInt" + j);

                    string age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
                }

                Table tblInfants = (Table)this.UpdatePanel2.FindControl("tblInfantsInt");
                for (int k = 1; k <= infantCntInt; k++)
                {
                    TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFnInt" + k);

                    TextBox txtLn = (TextBox)tblInfants.FindControl("txtILnInt" + k);

                    DropDownList ddlTitle = (DropDownList)tblInfants.FindControl("ddlITitleInt" + k);

                    TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDateInt" + k);
                    string age = string.Empty;
                    if (txtBirthDate != null)
                        age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                    else
                        age = "0";

                    if (customerInfo == string.Empty)
                    {
                        customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                    }
                    //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>inf</psgrtype></CustomerInfo>";
                }

                DataTable dtpricingreqBookingClass = dsIntFlights.Tables["BookingClass"];
                DataTable dtpricingreqBookingClassFare = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtpricingreqOnward = dsIntFlights.Tables["Onward"];
                DataTable dtpricingreqPsgrBreakUp = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtpricingreqPsgrAry = dsIntFlights.Tables["PsgrAry"];
                DataTable dtpricingreqPsgr = dsIntFlights.Tables["Psgr"];
                DataTable dtpricingreqTaxDataAry = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtpricingreqTaxData = dsIntFlights.Tables["TaxData"];
                if (dtpricingreqOnward.Rows.Count > 0)
                {
                    DataRow[] rowOnward = dtpricingreqOnward.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    onwardId = rowOnward[0]["onward_id"].ToString();
                }
                DataTable dtpricingreqFlightSegments = dsIntFlights.Tables["FlightSegments"];
                if (dtpricingreqFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegments = dtpricingreqFlightSegments.Select("onward_id=" + onwardId);
                    FlightSegmentsID = rowFlightSegments[0]["FlightSegments_Id"].ToString();
                }

                DataTable dtFlightSegment = dsIntFlights.Tables[12];
                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int j = 0; j < rowFilghtSegment.Length; j++)
                    {
                        AirEquipType = rowFilghtSegment[j]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFilghtSegment[j]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFilghtSegment[j]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFilghtSegment[j]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFilghtSegment[j]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFilghtSegment[j]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFilghtSegment[j]["DepartureDateTime"].ToString();
                        FlightNumber = rowFilghtSegment[j]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFilghtSegment[j]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFilghtSegment[j]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFilghtSegment[j]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFilghtSegment[j]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFilghtSegment[j]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFilghtSegment[j]["LinkSellAgrmnt"].ToString();
                        Conx = rowFilghtSegment[j]["Conx"].ToString();
                        AirpChg = rowFilghtSegment[j]["AirpChg"].ToString();
                        InsideAvailOption = rowFilghtSegment[j]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFilghtSegment[j]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFilghtSegment[j]["DaysOperates"].ToString();
                        JrnyTm = rowFilghtSegment[j]["JrnyTm"].ToString();
                        EndDt = rowFilghtSegment[j]["EndDt"].ToString();
                        StartTerminal = rowFilghtSegment[j]["StartTerminal"].ToString();
                        EndTerminal = rowFilghtSegment[j]["EndTerminal"].ToString();
                        FltTm = rowFilghtSegment[j]["FltTm"].ToString();
                        LSAInd = rowFilghtSegment[j]["LSAInd"].ToString();
                        Mile = rowFilghtSegment[j]["Mile"].ToString();
                        //   bookingclass = rowFilghtSegment[j]["LSAInd"].ToString();
                        //   classType = rowFilghtSegment[j]["Mile"].ToString();

                        if (dtpricingreqBookingClass.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtpricingreqBookingClass.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        if (dtpricingreqBookingClassFare.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtpricingreqBookingClassFare.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();
                            if (dtpricingreqBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                            {
                                bookingclassFareId = rowBookingClassFare[0]["bookingclassFare_Id"].ToString();
                            }
                        }
                        if (dtpricingreqBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            if (dtpricingreqPsgrBreakUp.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrBreakUp = dtpricingreqPsgrBreakUp.Select("bookingclassFare_Id=" + bookingclassFareId);
                                psgrBreakUp_Id = rowPsgrBreakUp[0]["psgrBreakUp_Id"].ToString();

                            }

                            if (dtpricingreqPsgrAry.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrAry = dtpricingreqPsgrAry.Select("psgrBreakUp_Id=" + psgrBreakUp_Id);
                                psgrAy_id = rowPsgrAry[0]["psgrAry_Id"].ToString();

                            }

                            if (dtpricingreqPsgr.Rows.Count > 0)
                            {
                                DataRow[] rowPsgr = dtpricingreqPsgr.Select("psgrAry_Id=" + psgrAy_id);
                                FarePsgrType = rowPsgr[0]["psgrType"].ToString();
                                FareBaseFare = rowPsgr[0]["BaseFare"].ToString();
                                FareTax1 = rowPsgr[0]["Tax"].ToString();
                                BagInfo = rowPsgr[0]["BagInfo"].ToString();

                            }
                        }
                        objFlightBal.FlightBookingID = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();//Convert.ToString(Session["BookingID"]);
                        objFlightBal.AirEquipType = AirEquipType;
                        objFlightBal.ArrivalAirportCode = ArrivalAirportCode;
                        objFlightBal.ArrivalAirportName = ArrivalAirportName;
                        objFlightBal.ArrivalDateTime = ArrivalDateTime;
                        objFlightBal.DepartureAirportCode = DepartureAirportCode;
                        objFlightBal.DepartureAirportName = DepartureAirportName;
                        objFlightBal.DepartureDateTime = DepartureDateTime;
                        objFlightBal.FlightNumber = FlightNumber;
                        objFlightBal.MarketingAirlineCode = MarketingAirlineCode;
                        objFlightBal.OperatingAirlineCode = OperatingAirlineCode;
                        objFlightBal.OperatingAirlineName = OperatingAirlineName;
                        objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumber;
                        objFlightBal.NumStops = NumStops;
                        objFlightBal.LinkSellAgrmnt = LinkSellAgrmnt;
                        objFlightBal.Conx = Conx;
                        objFlightBal.AirpChg = AirpChg;
                        objFlightBal.InsideAvailOption = InsideAvailOption;
                        objFlightBal.GenTrafRestriction = GenTrafRestriction;
                        objFlightBal.DaysOperates = DaysOperates;
                        objFlightBal.JrnyTm = JrnyTm;
                        objFlightBal.EndDt = EndDt;
                        objFlightBal.StartTerminal = StartTerminal;
                        objFlightBal.EndTerminal = EndTerminal;
                        objFlightBal.FltTm = FltTm;
                        objFlightBal.LSAInd = LSAInd;
                        objFlightBal.Mile = Mile;
                        objFlightBal.Availability = Availability;
                        objFlightBal.BIC = BIC;
                        objFlightBal.emailAddress = txtEmailIDInt.Text.Trim();
                        Session["EmailID"] = txtEmailIDInt.Text.Trim();
                        objFlightBal.telephone = txtMobileNumberInt.Text;
                        Session["MobileNo"] = txtMobileNumberInt.Text;
                        objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                        objFlightBal.Customer_Details = customerInfo;
                        objFlightBal.Address = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        Session["customerInfo"] = customerInfo;
                        Session["Address"] = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        objFlightBal.bookingClass = bookingclass;
                        objFlightBal.ClassType = classType;
                        objFlightBal.farebasisCode = farebasiscode;
                        objFlightBal.Fare_Rule = Rule;
                        objFlightBal.PsgrType = FarePsgrType;
                        objFlightBal.BaseFare = FareBaseFare;
                        objFlightBal.psgrTax = FareTax1;
                        objFlightBal.BagInfo = BagInfo;
                        objFlightBal.FarePsgrType = faretype;

                        res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);

                    }
                }

                DataTable dtpricingreqReturn = dsIntFlights.Tables["Return"];
                if (dtpricingreqReturn.Rows.Count > 0)
                {
                    DataRow[] rowReturn = dtpricingreqReturn.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    returnId = rowReturn[0]["return_id"].ToString();
                }
                DataTable dtpricingreqFlightSegmentsRet = dsIntFlights.Tables["FlightSegments"];
                if (dtpricingreqFlightSegmentsRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentsRet = dtpricingreqFlightSegmentsRet.Select("return_id=" + returnId);
                    FlightSegmentsIDRet = rowFlightSegmentsRet[0]["FlightSegments_Id"].ToString();
                }
                DataTable dtpricingreqFlightSegmentRet = dsIntFlights.Tables["FlightSegment"];
                DataTable dtpricingreqBookingClassRet = dsIntFlights.Tables["BookingClass"];
                DataTable dtpricingreqBookingClassFareRet = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtpricingreqPsgrBreakUpRet = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtpricingreqPsgrAryRet = dsIntFlights.Tables["PsgrAry"];
                DataTable dtpricingreqPsgrRet = dsIntFlights.Tables["Psgr"];
                DataTable dtpricingreqTaxDataAryRet = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtpricingreqTaxDataRet = dsIntFlights.Tables["TaxData"];

                if (dtpricingreqFlightSegmentRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentRet = dtpricingreqFlightSegmentRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                    for (int i = 0; i < rowFlightSegmentRet.Length; i++)
                    {

                        AirEquipTypeRet = rowFlightSegmentRet[i]["AirEquipType"].ToString();
                        ArrivalAirportCodeRet = rowFlightSegmentRet[i]["ArrivalAirportCode"].ToString();
                        ArrivalAirportNameRet = rowFlightSegmentRet[i]["ArrivalAirportName"].ToString();
                        ArrivalDateTimeRet = rowFlightSegmentRet[i]["ArrivalDateTime"].ToString();
                        DepartureAirportCodeRet = rowFlightSegmentRet[i]["DepartureAirportCode"].ToString();
                        DepartureAirportNameRet = rowFlightSegmentRet[i]["DepartureAirportName"].ToString();
                        DepartureDateTimeRet = rowFlightSegmentRet[i]["DepartureDateTime"].ToString();
                        FlightNumberRet = rowFlightSegmentRet[i]["FlightNumber"].ToString();
                        MarketingAirlineCodeRet = rowFlightSegmentRet[i]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCodeRet = rowFlightSegmentRet[i]["OperatingAirlineCode"].ToString();
                        OperatingAirlineNameRet = rowFlightSegmentRet[i]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumberRet = rowFlightSegmentRet[i]["OperatingAirlineFlightNumber"].ToString();
                        NumStopsRet = rowFlightSegmentRet[i]["NumStops"].ToString();
                        LinkSellAgrmntRet = rowFlightSegmentRet[i]["LinkSellAgrmnt"].ToString();
                        ConxRet = rowFlightSegmentRet[i]["Conx"].ToString();
                        AirpChgRet = rowFlightSegmentRet[i]["AirpChg"].ToString();
                        InsideAvailOptionRet = rowFlightSegmentRet[i]["InsideAvailOption"].ToString();
                        GenTrafRestrictionRet = rowFlightSegmentRet[i]["GenTrafRestriction"].ToString();
                        DaysOperatesRet = rowFlightSegmentRet[i]["DaysOperates"].ToString();
                        JrnyTmRet = rowFlightSegmentRet[i]["JrnyTm"].ToString();
                        EndDtRet = rowFlightSegmentRet[i]["EndDt"].ToString();
                        StartTerminalRet = rowFlightSegmentRet[i]["StartTerminal"].ToString();
                        EndTerminalRet = rowFlightSegmentRet[i]["EndTerminal"].ToString();
                        FltTmRet = rowFlightSegmentRet[i]["FltTm"].ToString();
                        LSAIndRet = rowFlightSegmentRet[i]["LSAInd"].ToString();
                        MileRet = rowFlightSegmentRet[i]["Mile"].ToString();

                        if (dtpricingreqBookingClassRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassRet = dtpricingreqBookingClassRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            AvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                            BICRet = rowBookingClassRet[0]["BIC"].ToString();
                        }

                        if (dtpricingreqBookingClassFareRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFareRet = dtpricingreqBookingClassFareRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                            classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                            farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                            RuleRet = rowBookingClassFareRet[0]["Rule"].ToString();
                            bookingclassFareIdRet = rowBookingClassFareRet[0]["bookingclassFare_Id"].ToString();

                        }

                        if (dtpricingreqPsgrBreakUpRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrBreakUpRet = dtpricingreqPsgrBreakUpRet.Select("bookingclassFare_Id=" + bookingclassFareIdRet);
                            psgrBreakUp_IdRet = rowPsgrBreakUpRet[0]["psgrBreakUp_Id"].ToString();

                        }

                        if (dtpricingreqPsgrAryRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrAryRet = dtpricingreqPsgrAryRet.Select("psgrBreakUp_Id=" + psgrBreakUp_IdRet);
                            psgrAy_idRet = rowPsgrAryRet[0]["psgrAry_Id"].ToString();

                        }

                        if (dtpricingreqPsgrRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrRet = dtpricingreqPsgrRet.Select("psgrAry_Id=" + psgrAy_idRet);
                            FarePsgrTypeRet = rowPsgrRet[0]["psgrType"].ToString();
                            FareBaseFareRet = rowPsgrRet[0]["BaseFare"].ToString();
                            FareTax1Ret = rowPsgrRet[0]["Tax"].ToString();
                            BagInfoRet = rowPsgrRet[0]["BagInfo"].ToString();

                        }
                        objFlightBal.FlightBookingID = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();//Convert.ToString(Session["BookingID"]);
                        objFlightBal.AirEquipType = AirEquipTypeRet;
                        objFlightBal.ArrivalAirportCode = ArrivalAirportCodeRet;
                        objFlightBal.ArrivalAirportName = ArrivalAirportNameRet;
                        objFlightBal.ArrivalDateTime = ArrivalDateTimeRet;
                        objFlightBal.DepartureAirportCode = DepartureAirportCodeRet;
                        objFlightBal.DepartureAirportName = DepartureAirportNameRet;
                        objFlightBal.DepartureDateTime = DepartureDateTimeRet;
                        objFlightBal.FlightNumber = FlightNumberRet;
                        objFlightBal.MarketingAirlineCode = MarketingAirlineCodeRet;
                        objFlightBal.OperatingAirlineCode = OperatingAirlineCodeRet;
                        objFlightBal.OperatingAirlineName = OperatingAirlineNameRet;
                        objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumberRet;
                        objFlightBal.NumStops = NumStopsRet;
                        objFlightBal.LinkSellAgrmnt = LinkSellAgrmntRet;
                        objFlightBal.Conx = ConxRet;
                        objFlightBal.AirpChg = AirpChgRet;
                        objFlightBal.InsideAvailOption = InsideAvailOptionRet;
                        objFlightBal.GenTrafRestriction = GenTrafRestrictionRet;
                        objFlightBal.DaysOperates = DaysOperatesRet;
                        objFlightBal.JrnyTm = JrnyTmRet;
                        objFlightBal.EndDt = EndDtRet;
                        objFlightBal.StartTerminal = StartTerminalRet;
                        objFlightBal.EndTerminal = EndTerminalRet;
                        objFlightBal.FltTm = FltTmRet;
                        objFlightBal.LSAInd = LSAIndRet;
                        objFlightBal.Mile = MileRet;
                        objFlightBal.Availability = AvailabilityRet;
                        objFlightBal.BIC = BICRet;
                        objFlightBal.emailAddress = txtEmailIDInt.Text.Trim();
                        Session["EmailID"] = txtEmailIDInt.Text.Trim();
                        objFlightBal.telephone = txtMobileNumberInt.Text;
                        Session["MobileNo"] = txtMobileNumberInt.Text;
                        objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                        objFlightBal.Customer_Details = customerInfo;
                        objFlightBal.Address = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        Session["customerInfo"] = customerInfo;
                        Session["Address"] = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                        objFlightBal.bookingClass = bookingclassRet;
                        objFlightBal.ClassType = classTypeRet;
                        objFlightBal.farebasisCode = farebasiscodeRet;
                        objFlightBal.Fare_Rule = RuleRet;
                        objFlightBal.PsgrType = FarePsgrTypeRet;
                        objFlightBal.BaseFare = FareBaseFareRet;
                        objFlightBal.psgrTax = FareTax1Ret;
                        objFlightBal.BagInfo = BagInfoRet;
                        objFlightBal.FarePsgrType = faretype;

                        res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);
                    }
                }

                if (res1 == true)
                {
                    Response.Redirect("~/pay.aspx?val=true", false);
                }

                //end db save
            }
            else
            {

                FlightBAL objFlightsBal = new FlightBAL();
                string xmlpricingrequestforInt = "<PriceRequest><noadults>" + ddlAdultsInt.SelectedValue + "</noadults><nochild>" + ddlChildsInt.SelectedValue + "</nochild><noinfant>" + ddlInfantsInt.SelectedValue + "</noinfant><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooINTLWS1.0</Clienttype>";
                xmlpricingrequestforInt = xmlpricingrequestforInt + "<OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry>" + str + "</FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails>";//<Fare><PsgrType>" + PsgrType + "</PsgrType><BaseFare>" + BaseFare + "</BaseFare><Tax>" + FareTax + "</Tax></Fare>
                xmlpricingrequestforInt = xmlpricingrequestforInt + "<onward><FlightSegments>";

                DataTable dtpricingreqOnward = dsIntFlights.Tables["Onward"];
                if (dtpricingreqOnward.Rows.Count > 0)
                {
                    DataRow[] rowOnward = dtpricingreqOnward.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    onwardId = rowOnward[0]["onward_id"].ToString();
                }
                DataTable dtpricingreqFlightSegments = dsIntFlights.Tables["FlightSegments"];
                if (dtpricingreqFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegments = dtpricingreqFlightSegments.Select("onward_id=" + onwardId);
                    FlightSegmentsID = rowFlightSegments[0]["FlightSegments_Id"].ToString();
                }
                DataTable dtpricingreqFlightSegment = dsIntFlights.Tables["FlightSegment"];
                DataTable dtpricingreqBookingClass = dsIntFlights.Tables["BookingClass"];
                DataTable dtpricingreqBookingClassFare = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtpricingreqPsgrBreakUp = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtpricingreqPsgrAry = dsIntFlights.Tables["PsgrAry"];
                DataTable dtpricingreqPsgr = dsIntFlights.Tables["Psgr"];
                DataTable dtpricingreqTaxDataAry = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtpricingreqTaxData = dsIntFlights.Tables["TaxData"];

                if (dtpricingreqFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegment = dtpricingreqFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int i = 0; i < rowFlightSegment.Length; i++)
                    {

                        AirEquipType = rowFlightSegment[i]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFlightSegment[i]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFlightSegment[i]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFlightSegment[i]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFlightSegment[i]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFlightSegment[i]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFlightSegment[i]["DepartureDateTime"].ToString();
                        FlightNumber = rowFlightSegment[i]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFlightSegment[i]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFlightSegment[i]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFlightSegment[i]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFlightSegment[i]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFlightSegment[i]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFlightSegment[i]["LinkSellAgrmnt"].ToString();
                        Conx = rowFlightSegment[i]["Conx"].ToString();
                        AirpChg = rowFlightSegment[i]["AirpChg"].ToString();
                        InsideAvailOption = rowFlightSegment[i]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFlightSegment[i]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFlightSegment[i]["DaysOperates"].ToString();
                        JrnyTm = rowFlightSegment[i]["JrnyTm"].ToString();
                        EndDt = rowFlightSegment[i]["EndDt"].ToString();
                        StartTerminal = rowFlightSegment[i]["StartTerminal"].ToString();
                        EndTerminal = rowFlightSegment[i]["EndTerminal"].ToString();
                        FltTm = rowFlightSegment[i]["FltTm"].ToString();
                        LSAInd = rowFlightSegment[i]["LSAInd"].ToString();
                        Mile = rowFlightSegment[i]["Mile"].ToString();

                        if (dtpricingreqBookingClass.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtpricingreqBookingClass.Select("FlightSegment_Id=" + rowFlightSegment[i]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        if (dtpricingreqBookingClassFare.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtpricingreqBookingClassFare.Select("FlightSegment_Id=" + rowFlightSegment[i]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();
                            if (dtpricingreqBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                            {
                                bookingclassFareId = rowBookingClassFare[0]["bookingclassFare_Id"].ToString();
                            }

                        }
                        if (dtpricingreqBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            if (dtpricingreqPsgrBreakUp.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrBreakUp = dtpricingreqPsgrBreakUp.Select("bookingclassFare_Id=" + bookingclassFareId);
                                psgrBreakUp_Id = rowPsgrBreakUp[0]["psgrBreakUp_Id"].ToString();

                            }

                            if (dtpricingreqPsgrAry.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrAry = dtpricingreqPsgrAry.Select("psgrBreakUp_Id=" + psgrBreakUp_Id);
                                psgrAy_id = rowPsgrAry[0]["psgrAry_Id"].ToString();

                            }

                            if (dtpricingreqPsgr.Rows.Count > 0)
                            {
                                DataRow[] rowPsgr = dtpricingreqPsgr.Select("psgrAry_Id=" + psgrAy_id);
                                FarePsgrType = rowPsgr[0]["psgrType"].ToString();
                                FareBaseFare = rowPsgr[0]["BaseFare"].ToString();
                                FareTax1 = rowPsgr[0]["Tax"].ToString();
                                BagInfo = rowPsgr[0]["BagInfo"].ToString();

                            }

                            if (dtpricingreqPsgr.Rows.Count > 0)
                            {
                                DataRow[] rowPsgr = dtpricingreqPsgr.Select("psgrAry_Id=" + psgrAy_id);
                                foreach (DataRow rows in rowPsgr)
                                {
                                    if (rows.Table.Rows.Count == 0)
                                    {
                                        taxdatapsgr = "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo>" + rows["BagInfo"].ToString() + "</BagInfo></Psgr>";
                                    }
                                    else
                                    {
                                        taxdatapsgr = taxdatapsgr + "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo>" + rows["BagInfo"].ToString() + "</BagInfo></Psgr>";
                                    }
                                }
                            }
                        }
                        if (dtpricingreqTaxDataAry.Rows.Count > 0)
                        {
                            DataRow[] rowTaxDataAry = dtpricingreqTaxDataAry.Select("Fare_id=" + FareId);
                            taxDataAry_id = rowTaxDataAry[0]["TaxdataAry_Id"].ToString();
                        }

                        if (dtpricingreqTaxData.Rows.Count > 0)
                        {
                            DataRow[] rowTaxData = dtpricingreqTaxData.Select("TaxdataAry_Id=" + taxDataAry_id);
                            for (int j = 0; j < rowTaxData.Length; j++)
                            {
                                if (rowTaxData.Length == 0)
                                {
                                    taxData = "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";
                                }
                                else
                                {
                                    taxData = taxData + "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";
                                }
                            }

                        }

                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportName + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportName + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber>";
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<MarketingAirlineCode>" + MarketingAirlineCode + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineName + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><NumStops>" + NumStops + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmnt + "</LinkSellAgrmnt><Conx>" + Conx + "</Conx><AirpChg>" + AirpChg + "</AirpChg><InsideAvailOption>" + InsideAvailOption + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestriction + "</GenTrafRestriction><DaysOperates>" + DaysOperates + "</DaysOperates><JrnyTm>" + JrnyTm + "</JrnyTm><EndDt>" + EndDt + "</EndDt><StartTerminal>" + StartTerminal + "</StartTerminal><EndTerminal>" + EndTerminal + "</EndTerminal>";
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<FltTm>" + FltTm + "</FltTm><LSAInd>" + LSAInd + "</LSAInd><Mile>" + Mile + "</Mile><BookingClass><Availability>" + Availability + "</Availability><BIC>" + BIC + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclass + "</bookingclass><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><Rule>" + Rule.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtpricingreqBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            xmlpricingrequestforInt = xmlpricingrequestforInt + "<PsgrBreakup><PsgrAry>" + taxdatapsgr + "</PsgrAry></PsgrBreakup>";
                        }
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "</BookingClassFare></FlightSegment>";//<Psgr><PsgrType>" + FarePsgrType + "</PsgrType><BaseFare>" + FareBaseFare + "</BaseFare><Tax>" + FareTax1 + "</Tax><BagInfo></BagInfo></Psgr>

                    }
                }

                xmlpricingrequestforInt = xmlpricingrequestforInt + "</FlightSegments></onward><Return><FlightSegments>";

                DataTable dtpricingreqReturn = dsIntFlights.Tables["Return"];
                if (dtpricingreqReturn.Rows.Count > 0)
                {
                    DataRow[] rowReturn = dtpricingreqReturn.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    returnId = rowReturn[0]["return_id"].ToString();
                }
                DataTable dtpricingreqFlightSegmentsRet = dsIntFlights.Tables["FlightSegments"];
                if (dtpricingreqFlightSegmentsRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentsRet = dtpricingreqFlightSegmentsRet.Select("return_id=" + returnId);
                    FlightSegmentsIDRet = rowFlightSegmentsRet[0]["FlightSegments_Id"].ToString();
                }
                DataTable dtpricingreqFlightSegmentRet = dsIntFlights.Tables["FlightSegment"];
                DataTable dtpricingreqBookingClassRet = dsIntFlights.Tables["BookingClass"];
                DataTable dtpricingreqBookingClassFareRet = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtpricingreqPsgrBreakUpRet = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtpricingreqPsgrAryRet = dsIntFlights.Tables["PsgrAry"];
                DataTable dtpricingreqPsgrRet = dsIntFlights.Tables["Psgr"];
                DataTable dtpricingreqTaxDataAryRet = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtpricingreqTaxDataRet = dsIntFlights.Tables["TaxData"];

                if (dtpricingreqFlightSegmentRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentRet = dtpricingreqFlightSegmentRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                    for (int i = 0; i < rowFlightSegmentRet.Length; i++)
                    {

                        AirEquipTypeRet = rowFlightSegmentRet[i]["AirEquipType"].ToString();
                        ArrivalAirportCodeRet = rowFlightSegmentRet[i]["ArrivalAirportCode"].ToString();
                        ArrivalAirportNameRet = rowFlightSegmentRet[i]["ArrivalAirportName"].ToString();
                        ArrivalDateTimeRet = rowFlightSegmentRet[i]["ArrivalDateTime"].ToString();
                        DepartureAirportCodeRet = rowFlightSegmentRet[i]["DepartureAirportCode"].ToString();
                        DepartureAirportNameRet = rowFlightSegmentRet[i]["DepartureAirportName"].ToString();
                        DepartureDateTimeRet = rowFlightSegmentRet[i]["DepartureDateTime"].ToString();
                        FlightNumberRet = rowFlightSegmentRet[i]["FlightNumber"].ToString();
                        MarketingAirlineCodeRet = rowFlightSegmentRet[i]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCodeRet = rowFlightSegmentRet[i]["OperatingAirlineCode"].ToString();
                        OperatingAirlineNameRet = rowFlightSegmentRet[i]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumberRet = rowFlightSegmentRet[i]["OperatingAirlineFlightNumber"].ToString();
                        NumStopsRet = rowFlightSegmentRet[i]["NumStops"].ToString();
                        LinkSellAgrmntRet = rowFlightSegmentRet[i]["LinkSellAgrmnt"].ToString();
                        ConxRet = rowFlightSegmentRet[i]["Conx"].ToString();
                        AirpChgRet = rowFlightSegmentRet[i]["AirpChg"].ToString();
                        InsideAvailOptionRet = rowFlightSegmentRet[i]["InsideAvailOption"].ToString();
                        GenTrafRestrictionRet = rowFlightSegmentRet[i]["GenTrafRestriction"].ToString();
                        DaysOperatesRet = rowFlightSegmentRet[i]["DaysOperates"].ToString();
                        JrnyTmRet = rowFlightSegmentRet[i]["JrnyTm"].ToString();
                        EndDtRet = rowFlightSegmentRet[i]["EndDt"].ToString();
                        StartTerminalRet = rowFlightSegmentRet[i]["StartTerminal"].ToString();
                        EndTerminalRet = rowFlightSegmentRet[i]["EndTerminal"].ToString();
                        FltTmRet = rowFlightSegmentRet[i]["FltTm"].ToString();
                        LSAIndRet = rowFlightSegmentRet[i]["LSAInd"].ToString();
                        MileRet = rowFlightSegmentRet[i]["Mile"].ToString();

                        if (dtpricingreqBookingClassRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassRet = dtpricingreqBookingClassRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            AvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                            BICRet = rowBookingClassRet[0]["BIC"].ToString();
                        }

                        if (dtpricingreqBookingClassFareRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFareRet = dtpricingreqBookingClassFareRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                            classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                            farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                            RuleRet = rowBookingClassFareRet[0]["Rule"].ToString();
                            if (dtpricingreqBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                            {
                                bookingclassFareIdRet = rowBookingClassFareRet[0]["bookingclassFare_Id"].ToString();
                            }
                        }
                        if (dtpricingreqBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                        {
                            if (dtpricingreqPsgrBreakUpRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrBreakUpRet = dtpricingreqPsgrBreakUpRet.Select("bookingclassFare_Id=" + bookingclassFareIdRet);
                                psgrBreakUp_IdRet = rowPsgrBreakUpRet[0]["psgrBreakUp_Id"].ToString();

                            }

                            if (dtpricingreqPsgrAryRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrAryRet = dtpricingreqPsgrAryRet.Select("psgrBreakUp_Id=" + psgrBreakUp_IdRet);
                                psgrAy_idRet = rowPsgrAryRet[0]["psgrAry_Id"].ToString();

                            }

                            if (dtpricingreqPsgrRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrRet = dtpricingreqPsgrRet.Select("psgrAry_Id=" + psgrAy_idRet);
                                FarePsgrTypeRet = rowPsgrRet[0]["psgrType"].ToString();
                                FareBaseFareRet = rowPsgrRet[0]["BaseFare"].ToString();
                                FareTax1Ret = rowPsgrRet[0]["Tax"].ToString();
                                BagInfoRet = rowPsgrRet[0]["BagInfo"].ToString();

                            }

                            if (dtpricingreqPsgrRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgr = dtpricingreqPsgrRet.Select("psgrAry_Id=" + psgrAy_idRet);
                                foreach (DataRow rows in rowPsgr)
                                {
                                    if (rows.Table.Rows.Count == 0)
                                    {
                                        taxdatapsgrRet = "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo>" + rows["BagInfo"].ToString() + "</BagInfo></Psgr>";
                                    }
                                    else
                                    {
                                        taxdatapsgrRet = taxdatapsgrRet + "<Psgr><PsgrType>" + rows["psgrType"].ToString() + "</PsgrType><BaseFare>" + rows["BaseFare"].ToString() + "</BaseFare><Tax>" + rows["Tax"].ToString() + "</Tax><BagInfo>" + rows["BagInfo"].ToString() + "</BagInfo></Psgr>";
                                    }
                                }
                            }
                        }
                        //if (dtTaxDataAryRet.Rows.Count > 0)
                        //{
                        //    DataRow[] rowTaxDataAryRet = dtTaxDataAryRet.Select("Fare_id=" + FareIdRet);
                        //    taxDataAry_id = rowTaxDataAryRet[0]["TaxdataAry_Id"].ToString();
                        //}

                        //if (dtTaxDataRet.Rows.Count > 0)
                        //{
                        //    DataRow[] rowTaxDataRet = dtTaxDataRet.Select("TaxdataAry_Id=" + taxDataAry_idRet);
                        //    for (int j = 0; j < rowTaxDataRet.Length; j++)
                        //    {
                        //        if (rowTaxDataRet.Length == 0)
                        //        {
                        //            taxDataRet = "<TaxData><Country>" + rowTaxDataRet[j]["Country"].ToString() + "</Country><Amt>" + rowTaxDataRet[j]["Amt"].ToString() + "</Amt></TaxData>";
                        //        }
                        //        else
                        //        {
                        //            taxDataRet = taxDataRet + "<TaxData><Country>" + rowTaxDataRet[j]["Country"].ToString() + "</Country><Amt>" + rowTaxDataRet[j]["Amt"].ToString() + "</Amt></TaxData>";
                        //        }
                        //    }

                        //}

                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<FlightSegment><AirEquipType>" + AirEquipTypeRet + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCodeRet + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportNameRet + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTimeRet + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCodeRet + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportNameRet + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTimeRet + "</DepartureDateTime><FlightNumber>" + FlightNumberRet + "</FlightNumber>";
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<MarketingAirlineCode>" + MarketingAirlineCodeRet + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCodeRet + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineNameRet + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumberRet + "</OperatingAirlineFlightNumber><NumStops>" + NumStopsRet + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmntRet + "</LinkSellAgrmnt><Conx>" + ConxRet + "</Conx><AirpChg>" + AirpChgRet + "</AirpChg><InsideAvailOption>" + InsideAvailOptionRet + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestrictionRet + "</GenTrafRestriction><DaysOperates>" + DaysOperatesRet + "</DaysOperates><JrnyTm>" + JrnyTmRet + "</JrnyTm><EndDt>" + EndDtRet + "</EndDt><StartTerminal>" + StartTerminalRet + "</StartTerminal><EndTerminal>" + EndTerminalRet + "</EndTerminal>";
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "<FltTm>" + FltTmRet + "</FltTm><LSAInd>" + LSAIndRet + "</LSAInd><Mile>" + MileRet + "</Mile><BookingClass><Availability>" + AvailabilityRet + "</Availability><BIC>" + BICRet + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclassRet + "</bookingclass><classType>" + classTypeRet + "</classType><farebasiscode>" + farebasiscodeRet + "</farebasiscode><Rule>" + RuleRet.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtpricingreqBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                        {
                            xmlpricingrequestforInt = xmlpricingrequestforInt + "<PsgrBreakup><PsgrAry>" + taxdatapsgrRet + "</PsgrAry></PsgrBreakup>";

                        }
                        xmlpricingrequestforInt = xmlpricingrequestforInt + "</BookingClassFare></FlightSegment>";//<Psgr><PsgrType>" + FarePsgrTypeRet + "</PsgrType><BaseFare>" + FareBaseFareRet + "</BaseFare><Tax>" + FareTax1Ret + "</Tax><BagInfo></BagInfo></Psgr>

                    }
                }
                xmlpricingrequestforInt = xmlpricingrequestforInt + "</FlightSegments></Return><id>" + id + "</id><key>" + key + "</key>";
                xmlpricingrequestforInt = xmlpricingrequestforInt + "</OriginDestinationOption></PriceRequest>";
                //                              <FlightSegment><AirEquipType>744</AirEquipType><ArrivalAirportCode>LHR</ArrivalAirportCode><ArrivalAirportName>LONDON&lt;BR&gt; (HEATHROW)</ArrivalAirportName><ArrivalDateTime>2010-02-24T06:55:00</ArrivalDateTime><DepartureAirportCode>BOM</DepartureAirportCode><DepartureAirportName>MUMBAI&lt;BR&gt;(CHHATRAPATI SHIVAJI INTERNATIONAL)</DepartureAirportName><DepartureDateTime>2010-02-24T02:45:00</DepartureDateTime><FlightNumber>138</FlightNumber><MarketingAirlineCode>BA</MarketingAirlineCode><OperatingAirlineCode>BA</OperatingAirlineCode><OperatingAirlineName>British Airways </OperatingAirlineName><OperatingAirlineFlightNumber>138</OperatingAirlineFlightNumber><NumStops>0</NumStops>" +
                //       "<LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>9</Availability><BIC>N</BIC></BookingClass><BookingClassFare><bookingclass>N</bookingclass><classType>Economy</classType><farebasiscode>NLRCAS|RP|V-BA|BOM-JFK</farebasiscode><Rule></Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>32000</BaseFare><Tax>21675</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment><FlightSegment>" +
                // "<AirEquipType>777</AirEquipType><ArrivalAirportCode>JFK</ArrivalAirportCode><ArrivalAirportName>NEW YORK&lt;BR&gt;(JOHN F KENNEDY INTL)</ArrivalAirportName><ArrivalDateTime>2010-02-24T13:55:00</ArrivalDateTime><DepartureAirportCode>LHR</DepartureAirportCode><DepartureAirportName>LONDON&lt;BR&gt; (HEATHROW)</DepartureAirportName><DepartureDateTime>2010-02-24T11:00:00</DepartureDateTime><FlightNumber>175</FlightNumber><MarketingAirlineCode>BA</MarketingAirlineCode><OperatingAirlineCode>BA</OperatingAirlineCode><OperatingAirlineName>British Airways </OperatingAirlineName><OperatingAirlineFlightNumber>175</OperatingAirlineFlightNumber><NumStops>0</NumStops>" +
                //     "<LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>9</Availability><BIC>N</BIC></BookingClass><BookingClassFare><bookingclass>N</bookingclass><classType>Economy</classType><farebasiscode>NLRCAS|RP|V-BA|BOM-JFK</farebasiscode><Rule></Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>32000</BaseFare><Tax>21675</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment></FlightSegments></onward>" +
                // "<Return><FlightSegments><FlightSegment><AirEquipType>777</AirEquipType><ArrivalAirportCode>LHR</ArrivalAirportCode><ArrivalAirportName>LONDON&lt;BR&gt; (HEATHROW)</ArrivalAirportName><ArrivalDateTime>2010-02-26T07:50:00</ArrivalDateTime><DepartureAirportCode>JFK</DepartureAirportCode><DepartureAirportName>NEW YORK&lt;BR&gt;(JOHN F KENNEDY INTL)</DepartureAirportName><DepartureDateTime>2010-02-25T19:40:00</DepartureDateTime><FlightNumber>176</FlightNumber>
                //<MarketingAirlineCode>BA</MarketingAirlineCode><OperatingAirlineCode>BA</OperatingAirlineCode>" +
                //    " <OperatingAirlineName>British Airways </OperatingAirlineName><OperatingAirlineFlightNumber>176</OperatingAirlineFlightNumber>
                //<NumStops>0</NumStops><LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>9</Availability><BIC>N</BIC></BookingClass><BookingClassFare><bookingclass>N</bookingclass><classType>Economy</classType><farebasiscode>NLRCAS|RP|V-BA|JFK-BOM</farebasiscode>" +
                // "<Rule></Rule><PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>32000</BaseFare><Tax>21675</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment><FlightSegment><AirEquipType>744</AirEquipType><ArrivalAirportCode>BOM</ArrivalAirportCode><ArrivalAirportName>MUMBAI&lt;BR&gt;(CHHATRAPATI SHIVAJI INTERNATIONAL)</ArrivalAirportName><ArrivalDateTime>2010-02-27T00:45:00</ArrivalDateTime><DepartureAirportCode>LHR</DepartureAirportCode><DepartureAirportName>LONDON&lt;BR&gt;(HEATHROW)</DepartureAirportName><DepartureDateTime>2010-02-26T10:30:00</DepartureDateTime><FlightNumber>139</FlightNumber><MarketingAirlineCode>BA</MarketingAirlineCode><OperatingAirlineCode>BA</OperatingAirlineCode>" +
                //    " <OperatingAirlineName>British Airways </OperatingAirlineName><OperatingAirlineFlightNumber>139</OperatingAirlineFlightNumber><NumStops>0</NumStops><LinkSellAgrmnt></LinkSellAgrmnt><Conx>N</Conx><AirpChg>N</AirpChg><InsideAvailOption>C</InsideAvailOption><GenTrafRestriction>?</GenTrafRestriction><DaysOperates>NA</DaysOperates><JrnyTm></JrnyTm><EndDt></EndDt><StartTerminal></StartTerminal><EndTerminal></EndTerminal><FltTm>0</FltTm><LSAInd>R</LSAInd><Mile>0</Mile><BookingClass><Availability>9</Availability><BIC>N</BIC></BookingClass><BookingClassFare><bookingclass>N</bookingclass><classType>Economy</classType><farebasiscode>NLRCAS|RP|V-BA|JFK-BOM</farebasiscode><Rule></Rule>" +
                //" <PsgrBreakup><PsgrAry><Psgr><PsgrType>ADT</PsgrType><BaseFare>32000</BaseFare><Tax>21675</Tax><BagInfo></BagInfo></Psgr></PsgrAry></PsgrBreakup></BookingClassFare></FlightSegment></FlightSegments></Return><id>arzoo35</id><key>pG4C0YQykzzTREhDdDdZxah4nJ/Bta4FgUl36m3L9/Vn4uu9m7LCssMPJ4Xz20E7cCU/hS9xGEdUAkpDcwlKw=</key></OriginDestinationOption></PriceRequest>";

                DataSet dsPricingResponse = objFlightsBal.GetDatasetFromAPI(xmlpricingrequestforInt, "http://live.arzoo.com:9302/Pricing");

                if (!dsPricingResponse.Tables[0].Columns.Contains("error"))
                {
                    DataTable dtpricingresFareDetails = dsPricingResponse.Tables["FareDetails"];
                    if (dtpricingresFareDetails.Rows.Count > 0)
                    {
                        DataRow[] rowFareDetails = dtpricingresFareDetails.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                        ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                        Tax = rowFareDetails[0]["Tax"].ToString();
                        STax = rowFareDetails[0]["STax"].ToString();
                        TCharge = rowFareDetails[0]["TCharge"].ToString();
                        SCharge = rowFareDetails[0]["SCharge"].ToString();
                        TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                        TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                        TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                        TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                        ocTax = rowFareDetails[0]["ocTax"].ToString();
                        FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
                    }
                }

            #endregion

                string ref1 = Common.GetFlightsReferenceNo("LJIF");
                string xmlRequest = "<Bookingrequest><noadults>" + ddlAdultsInt.SelectedValue + "</noadults><nochild>" + ddlChildsInt.SelectedValue + "</nochild><noinfant>" + ddlInfantsInt.SelectedValue + "</noinfant><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooINTLWS1.0</Clienttype><creditcardno></creditcardno><PartnerreferenceID>" + ref1 + "</PartnerreferenceID>";
                xmlRequest = xmlRequest + "<personName>";

                // Dynamic generation of names of adults, infants , Child
                Table tbladults = (Table)this.UpdatePanel2.FindControl("tblAdultsInt");
                for (int i = 1; i <= Convert.ToInt32(Session["adultCntInt"]); i++)
                {

                    TextBox txtFn = (TextBox)tbladults.FindControl("txtFnInt" + i);
                    TextBox txtLn = (TextBox)tbladults.FindControl("txtLnInt" + i);
                    DropDownList ddlTitle = (DropDownList)tbladults.FindControl("ddlTitleInt" + i);

                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
                }

                Table tblChild = (Table)this.UpdatePanel2.FindControl("tblChildInt");
                for (int i = 1; i <= Convert.ToInt32(Session["childCntInt"]); i++)
                {
                    TextBox txtFn = (TextBox)tblChild.FindControl("txtCFnInt" + i);

                    TextBox txtLn = (TextBox)tblChild.FindControl("txtCLnInt" + i);

                    DropDownList ddlTitle = (DropDownList)tblChild.FindControl("ddlCTitleInt" + i);

                    TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDateInt" + i);

                    string age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();

                    //if (Convert.ToInt32(age) > 5)
                    //{
                    //    Literal lit = new Literal();
                    //    lit.Text = "age is null";
                    //    this.Page.Controls.Add(lit);
                    //    break;
                    //}

                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
                }

                Table tblInfants = (Table)this.UpdatePanel2.FindControl("tblInfantsInt");
                for (int i = 1; i <= Convert.ToInt32(Session["infantCntInt"]); i++)
                {
                    TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFnInt" + i);

                    TextBox txtLn = (TextBox)tblInfants.FindControl("txtILnInt" + i);

                    DropDownList ddlTitle = (DropDownList)tblInfants.FindControl("ddlITitleInt" + i);

                    TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDateInt" + i);
                    string age = string.Empty;
                    if (txtBirthDate != null)
                        age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                    else
                        age = "0";
                    xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>inf</psgrtype></CustomerInfo>";
                }

                DataTable dtOriginDestinationOption = dsIntFlights.Tables["OriginDestinationOption"];
                if (dtOriginDestinationOption.Rows.Count > 0)
                {
                    DataRow[] rowOriginDestinationOption = dtOriginDestinationOption.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    id = rowOriginDestinationOption[0]["id"].ToString();
                    key = rowOriginDestinationOption[0]["key"].ToString();

                }

                //Get Details From roundtrip response
                DataTable dtFareDetails = dsIntFlights.Tables["FareDetails"];
                if (dtFareDetails.Rows.Count > 0)
                {
                    DataRow[] rowFareDetails = dtFareDetails.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                    Tax = rowFareDetails[0]["Tax"].ToString();
                    STax = rowFareDetails[0]["STax"].ToString();
                    TCharge = rowFareDetails[0]["TCharge"].ToString();
                    SCharge = rowFareDetails[0]["SCharge"].ToString();
                    TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                    TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                    TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                    TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                    ocTax = rowFareDetails[0]["ocTax"].ToString();
                    FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
                }
                DataTable dtFareBreakUp = dsIntFlights.Tables["FareBreakUp"];
                if (dtFareBreakUp.Rows.Count > 0)
                {
                    DataRow[] rowFareBreakUp = dtFareBreakUp.Select("FareDetails_Id=" + FareDetails_id);
                    FareBreakUp_Id = rowFareBreakUp[0]["FareBreakUp_Id"].ToString();

                }
                DataTable dtFareAry = dsIntFlights.Tables["FareAry"];
                if (dtFareAry.Rows.Count > 0)
                {
                    DataRow[] rowFareAry = dtFareAry.Select("FareBreakUp_Id=" + FareBreakUp_Id);
                    FareAry_id = rowFareAry[0]["FareAry_id"].ToString();
                }
                DataTable dtFare = dsIntFlights.Tables["Fare"];
                if (dtFare.Rows.Count > 0)
                {
                    DataRow[] rowFare = dtFare.Select("FareAry_id=" + FareAry_id);
                    PsgrType = rowFare[0]["PsgrType"].ToString();
                    BaseFare = rowFare[0]["BaseFare"].ToString();
                    FareTax = rowFare[0]["Tax"].ToString();
                    FareId = rowFare[0]["Fare_Id"].ToString();
                }

                xmlRequest = xmlRequest + "</personName><telePhone><phoneNumber>" + txtMobileNumInt.Text + "</phoneNumber></telePhone><email><emailAddress>" + txtEmailIDInt.Text + "</emailAddress></email>";
                xmlRequest = xmlRequest + "<OriginDestinationOption><FareDetails><ActualBaseFare>" + ActualBaseFare + "</ActualBaseFare><Tax>" + Tax + "</Tax><STax>" + STax + "</STax><TCharge>" + TCharge + "</TCharge><SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TMarkup>" + TMarkup + "</TMarkup><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission><TSdiscount>" + TSdiscount + "</TSdiscount><FareBreakup><FareAry>";//<Fare><PsgrType>" + PsgrType + "</PsgrType><BaseFare>" + BaseFare + "</BaseFare><Tax>" + FareTax + "</Tax>
                xmlRequest = xmlRequest + str + "</FareAry></FareBreakup><ocTax>" + ocTax + "</ocTax></FareDetails><onward><FlightSegments>";

                DataTable dtOnward = dsIntFlights.Tables["Onward"];
                if (dtOnward.Rows.Count > 0)
                {
                    DataRow[] rowOnward = dtOnward.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    onwardId = rowOnward[0]["onward_id"].ToString();
                }
                DataTable dtFlightSegments = dsIntFlights.Tables["FlightSegments"];
                if (dtFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegments = dtFlightSegments.Select("onward_id=" + onwardId);
                    FlightSegmentsID = rowFlightSegments[0]["FlightSegments_Id"].ToString();
                }
                DataTable dtFlightSegment = dsIntFlights.Tables["FlightSegment"];
                DataTable dtBookingClass = dsIntFlights.Tables["BookingClass"];
                DataTable dtBookingClassFare = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtPsgrBreakUp = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtPsgrAry = dsIntFlights.Tables["PsgrAry"];
                DataTable dtPsgr = dsIntFlights.Tables["Psgr"];
                DataTable dtTaxDataAry = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtTaxData = dsIntFlights.Tables["TaxData"];

                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                    for (int i = 0; i < rowFlightSegment.Length; i++)
                    {

                        AirEquipType = rowFlightSegment[i]["AirEquipType"].ToString();
                        ArrivalAirportCode = rowFlightSegment[i]["ArrivalAirportCode"].ToString();
                        ArrivalAirportName = rowFlightSegment[i]["ArrivalAirportName"].ToString();
                        ArrivalDateTime = rowFlightSegment[i]["ArrivalDateTime"].ToString();
                        DepartureAirportCode = rowFlightSegment[i]["DepartureAirportCode"].ToString();
                        DepartureAirportName = rowFlightSegment[i]["DepartureAirportName"].ToString();
                        DepartureDateTime = rowFlightSegment[i]["DepartureDateTime"].ToString();
                        FlightNumber = rowFlightSegment[i]["FlightNumber"].ToString();
                        MarketingAirlineCode = rowFlightSegment[i]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCode = rowFlightSegment[i]["OperatingAirlineCode"].ToString();
                        OperatingAirlineName = rowFlightSegment[i]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumber = rowFlightSegment[i]["OperatingAirlineFlightNumber"].ToString();
                        NumStops = rowFlightSegment[i]["NumStops"].ToString();
                        LinkSellAgrmnt = rowFlightSegment[i]["LinkSellAgrmnt"].ToString();
                        Conx = rowFlightSegment[i]["Conx"].ToString();
                        AirpChg = rowFlightSegment[i]["AirpChg"].ToString();
                        InsideAvailOption = rowFlightSegment[i]["InsideAvailOption"].ToString();
                        GenTrafRestriction = rowFlightSegment[i]["GenTrafRestriction"].ToString();
                        DaysOperates = rowFlightSegment[i]["DaysOperates"].ToString();
                        JrnyTm = rowFlightSegment[i]["JrnyTm"].ToString();
                        EndDt = rowFlightSegment[i]["EndDt"].ToString();
                        StartTerminal = rowFlightSegment[i]["StartTerminal"].ToString();
                        EndTerminal = rowFlightSegment[i]["EndTerminal"].ToString();
                        FltTm = rowFlightSegment[i]["FltTm"].ToString();
                        LSAInd = rowFlightSegment[i]["LSAInd"].ToString();
                        Mile = rowFlightSegment[i]["Mile"].ToString();

                        if (dtBookingClass.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtBookingClass.Select("FlightSegment_Id=" + rowFlightSegment[i]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }

                        if (dtBookingClassFare.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtBookingClassFare.Select("FlightSegment_Id=" + rowFlightSegment[i]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();
                            if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                            {
                                bookingclassFareId = rowBookingClassFare[0]["bookingclassFare_Id"].ToString();
                            }
                        }
                        if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {
                            if (dtPsgrBreakUp.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrBreakUp = dtPsgrBreakUp.Select("bookingclassFare_Id=" + bookingclassFareId);
                                psgrBreakUp_Id = rowPsgrBreakUp[0]["psgrBreakUp_Id"].ToString();

                            }

                            if (dtPsgrAry.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrAry = dtPsgrAry.Select("psgrBreakUp_Id=" + psgrBreakUp_Id);
                                psgrAy_id = rowPsgrAry[0]["psgrAry_Id"].ToString();

                            }

                            if (dtPsgr.Rows.Count > 0)
                            {
                                DataRow[] rowPsgr = dtPsgr.Select("psgrAry_Id=" + psgrAy_id);
                                FarePsgrType = rowPsgr[0]["psgrType"].ToString();
                                FareBaseFare = rowPsgr[0]["BaseFare"].ToString();
                                FareTax1 = rowPsgr[0]["Tax"].ToString();
                                BagInfo = rowPsgr[0]["BagInfo"].ToString();

                            }
                        }
                        if (dtTaxDataAry.Rows.Count > 0)
                        {
                            DataRow[] rowTaxDataAry = dtTaxDataAry.Select("Fare_id=" + FareId);
                            taxDataAry_id = rowTaxDataAry[0]["TaxdataAry_Id"].ToString();
                        }

                        if (dtTaxData.Rows.Count > 0)
                        {
                            DataRow[] rowTaxData = dtTaxData.Select("TaxdataAry_Id=" + taxDataAry_id);
                            for (int j = 0; j < rowTaxData.Length; j++)
                            {
                                if (rowTaxData.Length == 0)
                                {
                                    taxData = "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";
                                }
                                else
                                {
                                    taxData = taxData + "<TaxData><Country>" + rowTaxData[j]["Country"].ToString() + "</Country><Amt>" + rowTaxData[j]["Amt"].ToString() + "</Amt></TaxData>";
                                }
                            }

                        }

                        xmlRequest = xmlRequest + "<FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportName + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportName + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber>";
                        xmlRequest = xmlRequest + "<MarketingAirlineCode>" + MarketingAirlineCode + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineName + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><NumStops>" + NumStops + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmnt + "</LinkSellAgrmnt><Conx>" + Conx + "</Conx><AirpChg>" + AirpChg + "</AirpChg><InsideAvailOption>" + InsideAvailOption + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestriction + "</GenTrafRestriction><DaysOperates>" + DaysOperates + "</DaysOperates><JrnyTm>" + JrnyTm + "</JrnyTm><EndDt>" + EndDt + "</EndDt><StartTerminal>" + StartTerminal + "</StartTerminal><EndTerminal>" + EndTerminal + "</EndTerminal>";
                        xmlRequest = xmlRequest + "<FltTm>" + FltTm + "</FltTm><LSAInd>" + LSAInd + "</LSAInd><Mile>" + Mile + "</Mile><BookingClass><Availability>" + Availability + "</Availability><BIC>" + BIC + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclass + "</bookingclass><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><Rule>" + Rule.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtBookingClassFare.Columns.Contains("bookingclassFare_Id"))
                        {

                            xmlRequest = xmlRequest + "<PsgrBreakup><PsgrAry>" + taxdatapsgr + "</PsgrAry></PsgrBreakup>";
                        }
                        xmlRequest = xmlRequest + "</BookingClassFare></FlightSegment>";//<Psgr><PsgrType>" + FarePsgrType + "</PsgrType><BaseFare>" + FareBaseFare + "</BaseFare><Tax>" + FareTax1 + "</Tax><BagInfo></BagInfo></Psgr>

                    }
                }

                xmlRequest = xmlRequest + "</FlightSegments></onward><Return><FlightSegments>";

                DataTable dtReturn = dsIntFlights.Tables["Return"];
                if (dtReturn.Rows.Count > 0)
                {
                    DataRow[] rowReturn = dtReturn.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                    returnId = rowReturn[0]["return_id"].ToString();
                }
                DataTable dtFlightSegmentsRet = dsIntFlights.Tables["FlightSegments"];
                if (dtFlightSegmentsRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentsRet = dtFlightSegmentsRet.Select("return_id=" + returnId);
                    FlightSegmentsIDRet = rowFlightSegmentsRet[0]["FlightSegments_Id"].ToString();
                }
                DataTable dtFlightSegmentRet = dsIntFlights.Tables["FlightSegment"];
                DataTable dtBookingClassRet = dsIntFlights.Tables["BookingClass"];
                DataTable dtBookingClassFareRet = dsIntFlights.Tables["BookingClassFare"];
                DataTable dtPsgrBreakUpRet = dsIntFlights.Tables["PsgrBreakUp"];
                DataTable dtPsgrAryRet = dsIntFlights.Tables["PsgrAry"];
                DataTable dtPsgrRet = dsIntFlights.Tables["Psgr"];
                DataTable dtTaxDataAryRet = dsIntFlights.Tables["TaxDataAry"];
                DataTable dtTaxDataRet = dsIntFlights.Tables["TaxData"];

                if (dtFlightSegmentRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentRet = dtFlightSegmentRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                    for (int i = 0; i < rowFlightSegmentRet.Length; i++)
                    {

                        AirEquipTypeRet = rowFlightSegmentRet[i]["AirEquipType"].ToString();
                        ArrivalAirportCodeRet = rowFlightSegmentRet[i]["ArrivalAirportCode"].ToString();
                        ArrivalAirportNameRet = rowFlightSegmentRet[i]["ArrivalAirportName"].ToString();
                        ArrivalDateTimeRet = rowFlightSegmentRet[i]["ArrivalDateTime"].ToString();
                        DepartureAirportCodeRet = rowFlightSegmentRet[i]["DepartureAirportCode"].ToString();
                        DepartureAirportNameRet = rowFlightSegmentRet[i]["DepartureAirportName"].ToString();
                        DepartureDateTimeRet = rowFlightSegmentRet[i]["DepartureDateTime"].ToString();
                        FlightNumberRet = rowFlightSegmentRet[i]["FlightNumber"].ToString();
                        MarketingAirlineCodeRet = rowFlightSegmentRet[i]["MarketingAirlineCode"].ToString();
                        OperatingAirlineCodeRet = rowFlightSegmentRet[i]["OperatingAirlineCode"].ToString();
                        OperatingAirlineNameRet = rowFlightSegmentRet[i]["OperatingAirlineName"].ToString();
                        OperatingAirlineFlightNumberRet = rowFlightSegmentRet[i]["OperatingAirlineFlightNumber"].ToString();
                        NumStopsRet = rowFlightSegmentRet[i]["NumStops"].ToString();
                        LinkSellAgrmntRet = rowFlightSegmentRet[i]["LinkSellAgrmnt"].ToString();
                        ConxRet = rowFlightSegmentRet[i]["Conx"].ToString();
                        AirpChgRet = rowFlightSegmentRet[i]["AirpChg"].ToString();
                        InsideAvailOptionRet = rowFlightSegmentRet[i]["InsideAvailOption"].ToString();
                        GenTrafRestrictionRet = rowFlightSegmentRet[i]["GenTrafRestriction"].ToString();
                        DaysOperatesRet = rowFlightSegmentRet[i]["DaysOperates"].ToString();
                        JrnyTmRet = rowFlightSegmentRet[i]["JrnyTm"].ToString();
                        EndDtRet = rowFlightSegmentRet[i]["EndDt"].ToString();
                        StartTerminalRet = rowFlightSegmentRet[i]["StartTerminal"].ToString();
                        EndTerminalRet = rowFlightSegmentRet[i]["EndTerminal"].ToString();
                        FltTmRet = rowFlightSegmentRet[i]["FltTm"].ToString();
                        LSAIndRet = rowFlightSegmentRet[i]["LSAInd"].ToString();
                        MileRet = rowFlightSegmentRet[i]["Mile"].ToString();

                        if (dtBookingClassRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassRet = dtBookingClassRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            AvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                            BICRet = rowBookingClassRet[0]["BIC"].ToString();
                        }

                        if (dtBookingClassFareRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFareRet = dtBookingClassFareRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                            classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                            farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                            RuleRet = rowBookingClassFareRet[0]["Rule"].ToString();
                            if (dtBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                            {
                                bookingclassFareIdRet = rowBookingClassFareRet[0]["bookingclassFare_Id"].ToString();
                            }

                        }
                        if (dtBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                        {
                            if (dtPsgrBreakUpRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrBreakUpRet = dtPsgrBreakUpRet.Select("bookingclassFare_Id=" + bookingclassFareIdRet);
                                psgrBreakUp_IdRet = rowPsgrBreakUpRet[0]["psgrBreakUp_Id"].ToString();

                            }

                            if (dtPsgrAryRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrAryRet = dtPsgrAryRet.Select("psgrBreakUp_Id=" + psgrBreakUp_IdRet);
                                psgrAy_idRet = rowPsgrAryRet[0]["psgrAry_Id"].ToString();

                            }

                            if (dtPsgrRet.Rows.Count > 0)
                            {
                                DataRow[] rowPsgrRet = dtPsgrRet.Select("psgrAry_Id=" + psgrAy_idRet);
                                FarePsgrTypeRet = rowPsgrRet[0]["psgrType"].ToString();
                                FareBaseFareRet = rowPsgrRet[0]["BaseFare"].ToString();
                                FareTax1Ret = rowPsgrRet[0]["Tax"].ToString();
                                BagInfoRet = rowPsgrRet[0]["BagInfo"].ToString();

                            }
                        }
                        //if (dtTaxDataAryRet.Rows.Count > 0)
                        //{
                        //    DataRow[] rowTaxDataAryRet = dtTaxDataAryRet.Select("Fare_id=" + FareIdRet);
                        //    taxDataAry_id = rowTaxDataAryRet[0]["TaxdataAry_Id"].ToString();
                        //}

                        //if (dtTaxDataRet.Rows.Count > 0)
                        //{
                        //    DataRow[] rowTaxDataRet = dtTaxDataRet.Select("TaxdataAry_Id=" + taxDataAry_idRet);
                        //    for (int j = 0; j < rowTaxDataRet.Length; j++)
                        //    {
                        //        if (rowTaxDataRet.Length == 0)
                        //        {
                        //            taxDataRet = "<TaxData><Country>" + rowTaxDataRet[j]["Country"].ToString() + "</Country><Amt>" + rowTaxDataRet[j]["Amt"].ToString() + "</Amt></TaxData>";
                        //        }
                        //        else
                        //        {
                        //            taxDataRet = taxDataRet + "<TaxData><Country>" + rowTaxDataRet[j]["Country"].ToString() + "</Country><Amt>" + rowTaxDataRet[j]["Amt"].ToString() + "</Amt></TaxData>";
                        //        }
                        //    }

                        //}

                        xmlRequest = xmlRequest + "<FlightSegment><AirEquipType>" + AirEquipTypeRet + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCodeRet + "</ArrivalAirportCode><ArrivalAirportName>" + ArrivalAirportNameRet + "</ArrivalAirportName><ArrivalDateTime>" + ArrivalDateTimeRet + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCodeRet + "</DepartureAirportCode><DepartureAirportName>" + DepartureAirportNameRet + "</DepartureAirportName><DepartureDateTime>" + DepartureDateTimeRet + "</DepartureDateTime><FlightNumber>" + FlightNumberRet + "</FlightNumber>";
                        xmlRequest = xmlRequest + "<MarketingAirlineCode>" + MarketingAirlineCodeRet + "</MarketingAirlineCode><OperatingAirlineCode>" + OperatingAirlineCodeRet + "</OperatingAirlineCode><OperatingAirlineName>" + OperatingAirlineNameRet + "</OperatingAirlineName><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumberRet + "</OperatingAirlineFlightNumber><NumStops>" + NumStopsRet + "</NumStops><LinkSellAgrmnt>" + LinkSellAgrmntRet + "</LinkSellAgrmnt><Conx>" + ConxRet + "</Conx><AirpChg>" + AirpChgRet + "</AirpChg><InsideAvailOption>" + InsideAvailOptionRet + "</InsideAvailOption><GenTrafRestriction>" + GenTrafRestrictionRet + "</GenTrafRestriction><DaysOperates>" + DaysOperatesRet + "</DaysOperates><JrnyTm>" + JrnyTmRet + "</JrnyTm><EndDt>" + EndDtRet + "</EndDt><StartTerminal>" + StartTerminalRet + "</StartTerminal><EndTerminal>" + EndTerminalRet + "</EndTerminal>";
                        xmlRequest = xmlRequest + "<FltTm>" + FltTmRet + "</FltTm><LSAInd>" + LSAIndRet + "</LSAInd><Mile>" + MileRet + "</Mile><BookingClass><Availability>" + AvailabilityRet + "</Availability><BIC>" + BICRet + "</BIC></BookingClass><BookingClassFare><bookingclass>" + bookingclassRet + "</bookingclass><classType>" + classTypeRet + "</classType><farebasiscode>" + farebasiscodeRet + "</farebasiscode><Rule>" + RuleRet.Replace("<", "&lt;").Replace(">", "&gt;") + "</Rule>";
                        if (dtBookingClassFareRet.Columns.Contains("bookingclassFare_Id"))
                        {
                            xmlRequest = xmlRequest + "<PsgrBreakup><PsgrAry>" + taxdatapsgrRet + "</PsgrAry></PsgrBreakup>";
                        }
                        xmlRequest = xmlRequest + "</BookingClassFare></FlightSegment>";//<Psgr><PsgrType>" + FarePsgrTypeRet + "</PsgrType><BaseFare>" + FareBaseFareRet + "</BaseFare><Tax>" + FareTax1Ret + "</Tax><BagInfo></BagInfo></Psgr>

                    }
                }
                xmlRequest = xmlRequest + "</FlightSegments></Return><id>" + id + "</id><key>" + key + "</key>";
                xmlRequest = xmlRequest + "</OriginDestinationOption></Bookingrequest>";

                StringBuilder stt = new StringBuilder();

                stt.Append("xmlRequest");
                stt.Append("=");
                stt.Append(Server.UrlEncode(xmlRequest));

                byte[] requestData = Encoding.UTF8.GetBytes(stt.ToString());

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://live.arzoo.com:9302/Booking");
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.Accept = "application/json";

                request.ContentLength = requestData.Length;

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(requestData, 0, requestData.Length);
                }
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (Stream stream = response.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
                            result = reader.ReadToEnd();
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(result);
                        XmlNodeReader xmlReader = new XmlNodeReader(doc);

                        dsResponse.ReadXml(xmlReader);
                    }
                }
            }

        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("409"))
            {
                mp3.Show();
                lblerror.Visible = true;
                lblerror.Text = "Please contact administrator";
            }
        }
        return dsResponse;
    }
        private void GetRoundtripIntBookingRequest()
        {
        dsIntFlights = (DataSet)Session["dsIntFlights"];
        DataSet dsResponse = new DataSet();
        string result = string.Empty;
        try
        {

            #region Pricing

            DataTable dtPricingreqOriginDestinationOption = dsIntFlights.Tables["OriginDestinationOption"];
            if (dtPricingreqOriginDestinationOption.Rows.Count > 0)
            {
                DataRow[] rowOriginDestinationOption = dtPricingreqOriginDestinationOption.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                id1 = rowOriginDestinationOption[0]["id"].ToString();
                key = rowOriginDestinationOption[0]["key"].ToString();

            }

            //Get Details From roundtrip response
            DataTable dtPricingreqFareDetails = dsIntFlights.Tables["FareDetails"];
            if (dtPricingreqFareDetails.Rows.Count > 0)
            {
                DataRow[] rowFareDetails = dtPricingreqFareDetails.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                ActualBaseFare = rowFareDetails[0]["ActualBaseFare"].ToString();
                Tax = rowFareDetails[0]["Tax"].ToString();
                STax = rowFareDetails[0]["STax"].ToString();
                TCharge = rowFareDetails[0]["TCharge"].ToString();
                SCharge = rowFareDetails[0]["SCharge"].ToString();
                TDiscount = rowFareDetails[0]["TDiscount"].ToString();
                TMarkup = rowFareDetails[0]["TMarkup"].ToString();
                TPartnerCommission = rowFareDetails[0]["TPartnerCommission"].ToString();
                TSdiscount = rowFareDetails[0]["TSdiscount"].ToString();
                ocTax = rowFareDetails[0]["ocTax"].ToString();
                FareDetails_id = rowFareDetails[0]["FareDetails_id"].ToString();
            }
            DataTable dtPricingreqFareBreakUp = dsIntFlights.Tables["FareBreakUp"];
            if (dtPricingreqFareBreakUp.Rows.Count > 0)
            {
                DataRow[] rowFareBreakUp = dtPricingreqFareBreakUp.Select("FareDetails_Id=" + FareDetails_id);
                FareBreakUp_Id = rowFareBreakUp[0]["FareBreakUp_Id"].ToString();

            }
            DataTable dtPricingreqFareAry = dsIntFlights.Tables["FareAry"];
            if (dtPricingreqFareAry.Rows.Count > 0)
            {
                DataRow[] rowFareAry = dtPricingreqFareAry.Select("FareBreakUp_Id=" + FareBreakUp_Id);
                FareAry_id = rowFareAry[0]["FareAry_id"].ToString();
            }
            DataTable dtPricingreqFare = dsIntFlights.Tables["Fare"];
            if (dtPricingreqFare.Rows.Count > 0)
            {
                DataRow[] rowFare = dtPricingreqFare.Select("FareAry_id=" + FareAry_id);
                PsgrType = rowFare[0]["PsgrType"].ToString();
                BaseFare = rowFare[0]["BaseFare"].ToString();
                FareTax = rowFare[0]["Tax"].ToString();
                FareId = rowFare[0]["Fare_Id"].ToString();
                foreach (DataRow dr in rowFare)
                {
                    if (faretype == "")
                    {
                        faretype = dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString();
                    }
                    else
                    {

                        faretype = faretype + ";" + dr["PsgrType"].ToString() + "," + dr["BaseFare"].ToString() + "," + dr["Tax"].ToString() + ";";
                    }
                }
            }

            //db save
            FlightBAL objFlightBal = new FlightBAL();
            String RefNo = Common.GetFlightsReferenceNo("LJIF");
            Session["Order_Id"] = RefNo.ToString();
            objFlightBal.ReferenceNo = RefNo.ToString();
            objFlightBal.TransId = "0";
            objFlightBal.Status = "Pending";
            objFlightBal.AdultPax = Convert.ToInt32(Session["Adult"]);
            objFlightBal.InfantPax = Convert.ToInt32(Session["Infant"]);
            objFlightBal.ChildPax = Convert.ToInt32(Session["Child"]);
            objFlightBal.Origin_Destination_Id = id1;
            objFlightBal.Origin_Destination_Key = key;
            objFlightBal.ActualBasefare = Convert.ToDecimal(ActualBaseFare);
            objFlightBal.Tax = Convert.ToDecimal(Tax);
            objFlightBal.STax = Convert.ToDecimal(STax);
            objFlightBal.TCharge = Convert.ToDecimal(TCharge);
            objFlightBal.Scharge = Convert.ToDecimal(SCharge);
            objFlightBal.TDiscount = Convert.ToDecimal(TDiscount);
            objFlightBal.TMarkUp = Convert.ToDecimal(TMarkup);
            objFlightBal.TPartnerCommission = Convert.ToDecimal(TPartnerCommission);
            objFlightBal.TSDiscount = Convert.ToDecimal(TSdiscount);
            objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
            objFlightBal.TripMode = "Round";
            objFlightBal.ocTax = ocTax;
            //   objFlightBal.Return = return1;
            objFlightBal.id = id1;
            objFlightBal.key = key;

            DataTable dtflightBookingId = objFlightBal.AddDInternationalFlightBooking(objFlightBal);
            Session["BookingID"] = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();

            //fegments

            string customerInfo = string.Empty;
            Table tbladults = (Table)this.UpdatePanel2.FindControl("tblAdultsInt");
            for (int l = 1; l <= Convert.ToInt32(Session["adultCntInt"]); l++)
            {

                TextBox txtFn = (TextBox)tbladults.FindControl("txtFnInt" + l);
                TextBox txtLn = (TextBox)tbladults.FindControl("txtLnInt" + l);
                DropDownList ddlTitle = (DropDownList)tbladults.FindControl("ddlTitleInt" + l);

                if (customerInfo == string.Empty)
                {
                    customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                }
                else
                {
                    customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "adt" + "|" + "-";
                }
                //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
            }

            Table tblChild = (Table)this.UpdatePanel2.FindControl("tblChildInt");
            for (int j = 1; j <= childCntInt; j++)
            {
                TextBox txtFn = (TextBox)tblChild.FindControl("txtCFnInt" + j);

                TextBox txtLn = (TextBox)tblChild.FindControl("txtCLnInt" + j);

                DropDownList ddlTitle = (DropDownList)tblChild.FindControl("ddlCTitleInt" + j);

                TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDateInt" + j);

                string age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();

                if (customerInfo == string.Empty)
                {
                    customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                }
                else
                {
                    customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "chd" + "|" + age + "|" + txtBirthDate.Text;
                }
                //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
            }

            Table tblInfants = (Table)this.UpdatePanel2.FindControl("tblInfantsInt");
            for (int k = 1; k <= infantCntInt; k++)
            {
                TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFnInt" + k);

                TextBox txtLn = (TextBox)tblInfants.FindControl("txtILnInt" + k);

                DropDownList ddlTitle = (DropDownList)tblInfants.FindControl("ddlITitleInt" + k);

                TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDateInt" + k);
                string age = string.Empty;
                if (txtBirthDate != null)
                    age = (DateTime.Now.Year - Convert.ToDateTime(txtBirthDate.Text).Year).ToString();
                else
                    age = "0";

                if (customerInfo == string.Empty)
                {
                    customerInfo = ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                }
                else
                {
                    customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "inf" + "|" + age + "|" + txtBirthDate.Text;
                }
                //  xmlRequest = xmlRequest + "<CustomerInfo><givenName>" + txtFn.Text + "</givenName><surName>" + txtLn.Text + "</surName><nameReference>" + ddlTitle.SelectedItem.Value + "</nameReference><dob>" + txtBirthDate.Text + "</dob><age>" + age + "</age><psgrtype>inf</psgrtype></CustomerInfo>";
            }

            DataTable dtpricingreqBookingClass = dsIntFlights.Tables["BookingClass"];
            DataTable dtpricingreqBookingClassFare = dsIntFlights.Tables["BookingClassFare"];
            DataTable dtpricingreqOnward = dsIntFlights.Tables["Onward"];
            DataTable dtpricingreqPsgrBreakUp = dsIntFlights.Tables["PsgrBreakUp"];
            DataTable dtpricingreqPsgrAry = dsIntFlights.Tables["PsgrAry"];
            DataTable dtpricingreqPsgr = dsIntFlights.Tables["Psgr"];
            DataTable dtpricingreqTaxDataAry = dsIntFlights.Tables["TaxDataAry"];
            DataTable dtpricingreqTaxData = dsIntFlights.Tables["TaxData"];
            if (dtpricingreqOnward.Rows.Count > 0)
            {
                DataRow[] rowOnward = dtpricingreqOnward.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                onwardId = rowOnward[0]["onward_id"].ToString();
            }
            DataTable dtpricingreqFlightSegments = dsIntFlights.Tables["FlightSegments"];
            if (dtpricingreqFlightSegments.Rows.Count > 0)
            {
                DataRow[] rowFlightSegments = dtpricingreqFlightSegments.Select("onward_id=" + onwardId);
                FlightSegmentsID = rowFlightSegments[0]["FlightSegments_Id"].ToString();
            }

            DataTable dtFlightSegment = dsIntFlights.Tables[12];
            if (dtFlightSegment.Rows.Count > 0)
            {
                DataRow[] rowFilghtSegment = dtFlightSegment.Select("FlightSegments_Id=" + FlightSegmentsID);
                for (int j = 0; j < rowFilghtSegment.Length; j++)
                {
                    AirEquipType = rowFilghtSegment[j]["AirEquipType"].ToString();
                    ArrivalAirportCode = rowFilghtSegment[j]["ArrivalAirportCode"].ToString();
                    ArrivalAirportName = rowFilghtSegment[j]["ArrivalAirportName"].ToString();
                    ArrivalDateTime = rowFilghtSegment[j]["ArrivalDateTime"].ToString();
                    DepartureAirportCode = rowFilghtSegment[j]["DepartureAirportCode"].ToString();
                    DepartureAirportName = rowFilghtSegment[j]["DepartureAirportName"].ToString();
                    DepartureDateTime = rowFilghtSegment[j]["DepartureDateTime"].ToString();
                    FlightNumber = rowFilghtSegment[j]["FlightNumber"].ToString();
                    MarketingAirlineCode = rowFilghtSegment[j]["MarketingAirlineCode"].ToString();
                    OperatingAirlineCode = rowFilghtSegment[j]["OperatingAirlineCode"].ToString();
                    OperatingAirlineName = rowFilghtSegment[j]["OperatingAirlineName"].ToString();
                    OperatingAirlineFlightNumber = rowFilghtSegment[j]["OperatingAirlineFlightNumber"].ToString();
                    NumStops = rowFilghtSegment[j]["NumStops"].ToString();
                    LinkSellAgrmnt = rowFilghtSegment[j]["LinkSellAgrmnt"].ToString();
                    Conx = rowFilghtSegment[j]["Conx"].ToString();
                    AirpChg = rowFilghtSegment[j]["AirpChg"].ToString();
                    InsideAvailOption = rowFilghtSegment[j]["InsideAvailOption"].ToString();
                    GenTrafRestriction = rowFilghtSegment[j]["GenTrafRestriction"].ToString();
                    DaysOperates = rowFilghtSegment[j]["DaysOperates"].ToString();
                    JrnyTm = rowFilghtSegment[j]["JrnyTm"].ToString();
                    EndDt = rowFilghtSegment[j]["EndDt"].ToString();
                    StartTerminal = rowFilghtSegment[j]["StartTerminal"].ToString();
                    EndTerminal = rowFilghtSegment[j]["EndTerminal"].ToString();
                    FltTm = rowFilghtSegment[j]["FltTm"].ToString();
                    LSAInd = rowFilghtSegment[j]["LSAInd"].ToString();
                    Mile = rowFilghtSegment[j]["Mile"].ToString();
                    //   bookingclass = rowFilghtSegment[j]["LSAInd"].ToString();
                    //   classType = rowFilghtSegment[j]["Mile"].ToString();

                    if (dtpricingreqBookingClass != null)
                    {

                        if (dtpricingreqBookingClass.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClass = dtpricingreqBookingClass.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            Availability = rowBookingClass[0]["Availability"].ToString();
                            BIC = rowBookingClass[0]["BIC"].ToString();
                        }
                    }
                    if (dtpricingreqBookingClassFare != null)
                    {
                        if (dtpricingreqBookingClassFare.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFare = dtpricingreqBookingClassFare.Select("FlightSegment_Id=" + rowFilghtSegment[j]["FlightSegment_Id"].ToString());
                            bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                            classType = rowBookingClassFare[0]["classType"].ToString();
                            farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                            Rule = rowBookingClassFare[0]["Rule"].ToString();
                           // bookingclassFareId = rowBookingClassFare[0]["bookingclassFare_Id"].ToString();

                        }
                    }

                    if (dtpricingreqPsgrBreakUp != null)
                    {

                        if (dtpricingreqPsgrBreakUp.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrBreakUp = dtpricingreqPsgrBreakUp.Select("bookingclassFare_Id=" + bookingclassFareId);
                            psgrBreakUp_Id = rowPsgrBreakUp[0]["psgrBreakUp_Id"].ToString();

                        }
                    }

                    if (dtpricingreqPsgrAry != null)
                    {
                        if (dtpricingreqPsgrAry.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrAry = dtpricingreqPsgrAry.Select("psgrBreakUp_Id=" + psgrBreakUp_Id);
                            psgrAy_id = rowPsgrAry[0]["psgrAry_Id"].ToString();

                        }
                    }
                    if (dtpricingreqPsgr != null)
                    {
                        if (dtpricingreqPsgr.Rows.Count > 0)
                        {
                            DataRow[] rowPsgr = dtpricingreqPsgr.Select("psgrAry_Id=" + psgrAy_id);
                            FarePsgrType = rowPsgr[0]["psgrType"].ToString();
                            FareBaseFare = rowPsgr[0]["BaseFare"].ToString();
                            FareTax1 = rowPsgr[0]["Tax"].ToString();
                            BagInfo = rowPsgr[0]["BagInfo"].ToString();

                        }
                    }
                    objFlightBal.FlightBookingID = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();//Convert.ToString(Session["BookingID"]);
                    objFlightBal.AirEquipType = AirEquipType;
                    objFlightBal.ArrivalAirportCode = ArrivalAirportCode;
                    objFlightBal.ArrivalAirportName = ArrivalAirportName;
                    objFlightBal.ArrivalDateTime = ArrivalDateTime;
                    objFlightBal.DepartureAirportCode = DepartureAirportCode;
                    objFlightBal.DepartureAirportName = DepartureAirportName;
                    objFlightBal.DepartureDateTime = DepartureDateTime;
                    objFlightBal.FlightNumber = FlightNumber;
                    objFlightBal.MarketingAirlineCode = MarketingAirlineCode;
                    objFlightBal.OperatingAirlineCode = OperatingAirlineCode;
                    objFlightBal.OperatingAirlineName = OperatingAirlineName;
                    objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumber;
                    objFlightBal.NumStops = NumStops;
                    objFlightBal.LinkSellAgrmnt = LinkSellAgrmnt;
                    objFlightBal.Conx = Conx;
                    objFlightBal.AirpChg = AirpChg;
                    objFlightBal.InsideAvailOption = InsideAvailOption;
                    objFlightBal.GenTrafRestriction = GenTrafRestriction;
                    objFlightBal.DaysOperates = DaysOperates;
                    objFlightBal.JrnyTm = JrnyTm;
                    objFlightBal.EndDt = EndDt;
                    objFlightBal.StartTerminal = StartTerminal;
                    objFlightBal.EndTerminal = EndTerminal;
                    objFlightBal.FltTm = FltTm;
                    objFlightBal.LSAInd = LSAInd;
                    objFlightBal.Mile = Mile;
                    objFlightBal.Availability = Availability;
                    objFlightBal.BIC = BIC;
                    objFlightBal.emailAddress = txtEmailIDInt.Text.Trim();
                    Session["EmailID"] = txtEmailIDInt.Text.Trim();
                    objFlightBal.telephone = txtMobileNumberInt.Text;
                    Session["MobileNo"] = txtMobileNumberInt.Text;
                    objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                    objFlightBal.Customer_Details = customerInfo;
                    objFlightBal.Address = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                    Session["customerInfo"] = customerInfo;
                    Session["Address"] = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                    objFlightBal.bookingClass = bookingclass;
                    objFlightBal.ClassType = classType;
                    objFlightBal.farebasisCode = farebasiscode;
                    objFlightBal.Fare_Rule = Rule;
                    objFlightBal.PsgrType = FarePsgrType;
                    objFlightBal.BaseFare = FareBaseFare;
                    objFlightBal.psgrTax = FareTax1;
                    objFlightBal.BagInfo = BagInfo;
                    objFlightBal.FarePsgrType = faretype;

                    res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);

                }
            }

            DataTable dtpricingreqReturn = dsIntFlights.Tables["Return"];
            if (dtpricingreqReturn.Rows.Count > 0)
            {
                DataRow[] rowReturn = dtpricingreqReturn.Select("OriginDestinationOption_Id=" + lblOriginDestinationRoundTrip.Text);
                returnId = rowReturn[0]["return_id"].ToString();
            }
            DataTable dtpricingreqFlightSegmentsRet = dsIntFlights.Tables["FlightSegments"];
            if (dtpricingreqFlightSegmentsRet.Rows.Count > 0)
            {
                DataRow[] rowFlightSegmentsRet = dtpricingreqFlightSegmentsRet.Select("return_id=" + returnId);
                FlightSegmentsIDRet = rowFlightSegmentsRet[0]["FlightSegments_Id"].ToString();
            }
            DataTable dtpricingreqFlightSegmentRet = dsIntFlights.Tables["FlightSegment"];
            DataTable dtpricingreqBookingClassRet = dsIntFlights.Tables["BookingClass"];
            DataTable dtpricingreqBookingClassFareRet = dsIntFlights.Tables["BookingClassFare"];
            DataTable dtpricingreqPsgrBreakUpRet = dsIntFlights.Tables["PsgrBreakUp"];
            DataTable dtpricingreqPsgrAryRet = dsIntFlights.Tables["PsgrAry"];
            DataTable dtpricingreqPsgrRet = dsIntFlights.Tables["Psgr"];
            DataTable dtpricingreqTaxDataAryRet = dsIntFlights.Tables["TaxDataAry"];
            DataTable dtpricingreqTaxDataRet = dsIntFlights.Tables["TaxData"];

            if (dtpricingreqFlightSegmentRet.Rows.Count > 0)
            {
                DataRow[] rowFlightSegmentRet = dtpricingreqFlightSegmentRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                for (int i = 0; i < rowFlightSegmentRet.Length; i++)
                {

                    AirEquipTypeRet = rowFlightSegmentRet[i]["AirEquipType"].ToString();
                    ArrivalAirportCodeRet = rowFlightSegmentRet[i]["ArrivalAirportCode"].ToString();
                    ArrivalAirportNameRet = rowFlightSegmentRet[i]["ArrivalAirportName"].ToString();
                    ArrivalDateTimeRet = rowFlightSegmentRet[i]["ArrivalDateTime"].ToString();
                    DepartureAirportCodeRet = rowFlightSegmentRet[i]["DepartureAirportCode"].ToString();
                    DepartureAirportNameRet = rowFlightSegmentRet[i]["DepartureAirportName"].ToString();
                    DepartureDateTimeRet = rowFlightSegmentRet[i]["DepartureDateTime"].ToString();
                    FlightNumberRet = rowFlightSegmentRet[i]["FlightNumber"].ToString();
                    MarketingAirlineCodeRet = rowFlightSegmentRet[i]["MarketingAirlineCode"].ToString();
                    OperatingAirlineCodeRet = rowFlightSegmentRet[i]["OperatingAirlineCode"].ToString();
                    OperatingAirlineNameRet = rowFlightSegmentRet[i]["OperatingAirlineName"].ToString();
                    OperatingAirlineFlightNumberRet = rowFlightSegmentRet[i]["OperatingAirlineFlightNumber"].ToString();
                    NumStopsRet = rowFlightSegmentRet[i]["NumStops"].ToString();
                    LinkSellAgrmntRet = rowFlightSegmentRet[i]["LinkSellAgrmnt"].ToString();
                    ConxRet = rowFlightSegmentRet[i]["Conx"].ToString();
                    AirpChgRet = rowFlightSegmentRet[i]["AirpChg"].ToString();
                    InsideAvailOptionRet = rowFlightSegmentRet[i]["InsideAvailOption"].ToString();
                    GenTrafRestrictionRet = rowFlightSegmentRet[i]["GenTrafRestriction"].ToString();
                    DaysOperatesRet = rowFlightSegmentRet[i]["DaysOperates"].ToString();
                    JrnyTmRet = rowFlightSegmentRet[i]["JrnyTm"].ToString();
                    EndDtRet = rowFlightSegmentRet[i]["EndDt"].ToString();
                    StartTerminalRet = rowFlightSegmentRet[i]["StartTerminal"].ToString();
                    EndTerminalRet = rowFlightSegmentRet[i]["EndTerminal"].ToString();
                    FltTmRet = rowFlightSegmentRet[i]["FltTm"].ToString();
                    LSAIndRet = rowFlightSegmentRet[i]["LSAInd"].ToString();
                    MileRet = rowFlightSegmentRet[i]["Mile"].ToString();

                    if (dtpricingreqBookingClassRet != null)
                    {
                        if (dtpricingreqBookingClassRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassRet = dtpricingreqBookingClassRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            AvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                            BICRet = rowBookingClassRet[0]["BIC"].ToString();
                        }
                    }
                    if (dtpricingreqBookingClassFareRet != null)
                    {
                        if (dtpricingreqBookingClassFareRet.Rows.Count > 0)
                        {
                            DataRow[] rowBookingClassFareRet = dtpricingreqBookingClassFareRet.Select("FlightSegment_Id=" + rowFlightSegmentRet[i]["FlightSegment_Id"].ToString());
                            bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                            classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                            farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                            RuleRet = rowBookingClassFareRet[0]["Rule"].ToString();
                           // bookingclassFareIdRet = rowBookingClassFareRet[0]["bookingclassFare_Id"].ToString();

                        }
                    }
                    if (dtpricingreqPsgrBreakUpRet != null)
                    {

                        if (dtpricingreqPsgrBreakUpRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrBreakUpRet = dtpricingreqPsgrBreakUpRet.Select("bookingclassFare_Id=" + bookingclassFareIdRet);
                            psgrBreakUp_IdRet = rowPsgrBreakUpRet[0]["psgrBreakUp_Id"].ToString();

                        }
                    }
                    if (dtpricingreqPsgrAryRet != null)
                    {

                        if (dtpricingreqPsgrAryRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrAryRet = dtpricingreqPsgrAryRet.Select("psgrBreakUp_Id=" + psgrBreakUp_IdRet);
                            psgrAy_idRet = rowPsgrAryRet[0]["psgrAry_Id"].ToString();

                        }
                    }

                    if (dtpricingreqPsgrRet != null)
                    {
                        if (dtpricingreqPsgrRet.Rows.Count > 0)
                        {
                            DataRow[] rowPsgrRet = dtpricingreqPsgrRet.Select("psgrAry_Id=" + psgrAy_idRet);
                            FarePsgrTypeRet = rowPsgrRet[0]["psgrType"].ToString();
                            FareBaseFareRet = rowPsgrRet[0]["BaseFare"].ToString();
                            FareTax1Ret = rowPsgrRet[0]["Tax"].ToString();
                            BagInfoRet = rowPsgrRet[0]["BagInfo"].ToString();

                        }
                    }
                    objFlightBal.FlightBookingID = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();//Convert.ToString(Session["BookingID"]);
                    objFlightBal.AirEquipType = AirEquipTypeRet;
                    objFlightBal.ArrivalAirportCode = ArrivalAirportCodeRet;
                    objFlightBal.ArrivalAirportName = ArrivalAirportNameRet;
                    objFlightBal.ArrivalDateTime = ArrivalDateTimeRet;
                    objFlightBal.DepartureAirportCode = DepartureAirportCodeRet;
                    objFlightBal.DepartureAirportName = DepartureAirportNameRet;
                    objFlightBal.DepartureDateTime = DepartureDateTimeRet;
                    objFlightBal.FlightNumber = FlightNumberRet;
                    objFlightBal.MarketingAirlineCode = MarketingAirlineCodeRet;
                    objFlightBal.OperatingAirlineCode = OperatingAirlineCodeRet;
                    objFlightBal.OperatingAirlineName = OperatingAirlineNameRet;
                    objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumberRet;
                    objFlightBal.NumStops = NumStopsRet;
                    objFlightBal.LinkSellAgrmnt = LinkSellAgrmntRet;
                    objFlightBal.Conx = ConxRet;
                    objFlightBal.AirpChg = AirpChgRet;
                    objFlightBal.InsideAvailOption = InsideAvailOptionRet;
                    objFlightBal.GenTrafRestriction = GenTrafRestrictionRet;
                    objFlightBal.DaysOperates = DaysOperatesRet;
                    objFlightBal.JrnyTm = JrnyTmRet;
                    objFlightBal.EndDt = EndDtRet;
                    objFlightBal.StartTerminal = StartTerminalRet;
                    objFlightBal.EndTerminal = EndTerminalRet;
                    objFlightBal.FltTm = FltTmRet;
                    objFlightBal.LSAInd = LSAIndRet;
                    objFlightBal.Mile = MileRet;
                    objFlightBal.Availability = AvailabilityRet;
                    objFlightBal.BIC = BICRet;
                    objFlightBal.emailAddress = txtEmailIDInt.Text.Trim();
                    Session["EmailID"] = txtEmailIDInt.Text.Trim();
                    objFlightBal.telephone = txtMobileNumberInt.Text;
                    Session["MobileNo"] = txtMobileNumberInt.Text;
                    objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                    objFlightBal.Customer_Details = customerInfo;
                    objFlightBal.Address = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                    Session["customerInfo"] = customerInfo;
                    Session["Address"] = txtCityInt.Text + "," + txtStateInt.Text + "," + ddlCountryInt.SelectedValue + "," + txtPostalCodeInt.Text + ",";
                    objFlightBal.bookingClass = bookingclassRet;
                    objFlightBal.ClassType = classTypeRet;
                    objFlightBal.farebasisCode = farebasiscodeRet;
                    objFlightBal.Fare_Rule = RuleRet;
                    objFlightBal.PsgrType = FarePsgrTypeRet;
                    objFlightBal.BaseFare = FareBaseFareRet;
                    objFlightBal.psgrTax = FareTax1Ret;
                    objFlightBal.BagInfo = BagInfoRet;
                    objFlightBal.FarePsgrType = faretype;

                    res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);
                }
            }

            if (res1 == true)
            {
               // PaymentGateway();
                Session["result"] = "true";
            }

            //end db save

        }
        catch (Exception ex)
        {

            throw;
        }

        }