コード例 #1
0
    protected void btnRoundTripSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            try
            {
                // if (Session["UserID"] == null) { Response.Redirect("~/Default.aspx", false); return; }

                #region Variables

                string FlightSegmentsID = string.Empty;
                string originDestination_Id = string.Empty;
                string fareDetailsId = string.Empty;
                string TotalFare = string.Empty;
                string AirEquipType = string.Empty;
                string ArrivalAirportCode = string.Empty;
                string ArrivalDateTime = string.Empty;
                string DepartureAirportCode = string.Empty;
                string DepartureDateTime = string.Empty;
                string FlightNumber = string.Empty;
                string OperatingAirlineCode = string.Empty;
                string OperatingAirlineFlightNumber = string.Empty;
                string RPH = string.Empty;
                string StopQuantity = string.Empty;
                string airLineName = string.Empty;
                string airportTax = string.Empty;
                string imageFileName = string.Empty;
                string BookingClassAvailability = string.Empty;
                string BookingClassResBookDesigCode = string.Empty;
                string adultFare = string.Empty;
                string bookingclass = string.Empty;
                string childFare = string.Empty;
                string classType = string.Empty;
                string farebasiscode = string.Empty;
                string infantfare = string.Empty;
                string Rule = string.Empty;
                string adultCommission = string.Empty;
                string childCommission = string.Empty;
                string commissionOnTCharge = string.Empty;
                string Discount = string.Empty;
                string airportTaxChild = string.Empty;
                string airportTaxInfant = string.Empty;
                string adultTaxBreakup = string.Empty;
                string childTaxBreakup = string.Empty;
                string infantTaxBreakup = string.Empty;
                string octax = string.Empty;
                string id = string.Empty;
                string key = string.Empty;
                string TCharge = string.Empty;
                string TMarkup = string.Empty;
                string TSdiscount = string.Empty;
                string TPartnerCommission = string.Empty;
                string actualBaseFare = string.Empty;
                string tax = string.Empty;
                string Stax = string.Empty;
                string SCharge = string.Empty;
                string TDiscount = string.Empty;

                string responseDepartId = string.Empty;
                string responseReturnId = string.Empty;
                string OriginDestinationOptionsId = string.Empty;

                #endregion
                dsFilghts = (DataSet)Session["dsDomFlights"];

                DataTable dtFlightSegment = dsFilghts.Tables["FlightSegment"];

                if (dtFlightSegment.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegment = dtFlightSegment.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                    AirEquipType = rowFlightSegment[0]["AirEquipType"].ToString();
                    ArrivalAirportCode = rowFlightSegment[0]["ArrivalAirportCode"].ToString();
                    ArrivalDateTime = rowFlightSegment[0]["ArrivalDateTime"].ToString();
                    DepartureAirportCode = rowFlightSegment[0]["DepartureAirportCode"].ToString();
                    DepartureDateTime = rowFlightSegment[0]["DepartureDateTime"].ToString();
                    FlightNumber = rowFlightSegment[0]["FlightNumber"].ToString();
                    OperatingAirlineCode = rowFlightSegment[0]["OperatingAirlineCode"].ToString();
                    OperatingAirlineFlightNumber = rowFlightSegment[0]["OperatingAirlineFlightNumber"].ToString();
                    RPH = rowFlightSegment[0]["RPH"].ToString();
                    StopQuantity = rowFlightSegment[0]["StopQuantity"].ToString();
                    airLineName = rowFlightSegment[0]["airLineName"].ToString();
                    airportTax = rowFlightSegment[0]["airportTax"].ToString();
                    imageFileName = rowFlightSegment[0]["imageFileName"].ToString();
                    Discount = rowFlightSegment[0]["Discount"].ToString();
                    airportTaxChild = rowFlightSegment[0]["airportTaxChild"].ToString();
                    airportTaxInfant = rowFlightSegment[0]["airportTaxInfant"].ToString();
                    adultTaxBreakup = rowFlightSegment[0]["adultTaxBreakup"].ToString();
                    childTaxBreakup = rowFlightSegment[0]["childTaxBreakup"].ToString();
                    infantTaxBreakup = rowFlightSegment[0]["infantTaxBreakup"].ToString();
                    octax = rowFlightSegment[0]["octax"].ToString();
                    FlightSegmentsID = rowFlightSegment[0]["FlightSegments_Id"].ToString();
                }

                DataTable dtFlightSegments = dsFilghts.Tables["FlightSegments"];

                if (dtFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegments = dtFlightSegments.Select("FlightSegments_Id=" + FlightSegmentsID);
                    originDestination_Id = rowFlightSegments[0]["originDestinationoption_Id"].ToString();
                }
                DataTable dtoriginDestinationoption = dsFilghts.Tables["originDestinationoption"];

                if (dtoriginDestinationoption.Rows.Count > 0)
                {
                    DataRow[] roworiginDestinationoption = dtoriginDestinationoption.Select("originDestinationoption_Id=" + originDestination_Id);
                    id = roworiginDestinationoption[0]["id"].ToString();
                    key = roworiginDestinationoption[0]["key"].ToString();
                }

                DataTable dtFareDetails = dsFilghts.Tables["FareDetails"];

                if (dtFareDetails.Rows.Count > 0)
                {
                    DataRow[] rowFareDetails = dtFareDetails.Select("originDestinationoption_Id=" + originDestination_Id);
                    fareDetailsId = rowFareDetails[0]["FareDetails_Id"].ToString();
                }

                DataTable dtChargeableFares = dsFilghts.Tables["ChargeableFares"];
                if (dtChargeableFares.Rows.Count > 0)
                {
                    DataRow[] rowChargeableFares = dtChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                    actualBaseFare = rowChargeableFares[0]["ActualBaseFare"].ToString();
                    tax = rowChargeableFares[0]["tax"].ToString();
                    Stax = rowChargeableFares[0]["Stax"].ToString();
                    SCharge = rowChargeableFares[0]["SCharge"].ToString();
                    TDiscount = rowChargeableFares[0]["TDiscount"].ToString();
                    TPartnerCommission = rowChargeableFares[0]["TPartnerCommission"].ToString();

                }

                DataTable dtNonChargeableFares = dsFilghts.Tables["NonChargeableFares"];
                if (dtNonChargeableFares.Rows.Count > 0)
                {
                    DataRow[] rowNonChargeableFares = dtNonChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                    TCharge = rowNonChargeableFares[0]["TCharge"].ToString();
                    TSdiscount = rowNonChargeableFares[0]["TSdiscount"].ToString();
                    TMarkup = rowNonChargeableFares[0]["TMarkup"].ToString();
                }
                DataTable dtBookingClass = dsFilghts.Tables["BookingClass"];
                if (dtBookingClass.Rows.Count > 0)
                {
                    DataRow[] rowBookingClass = dtBookingClass.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                    BookingClassAvailability = rowBookingClass[0]["Availability"].ToString();
                    BookingClassResBookDesigCode = rowBookingClass[0]["ResBookDesigCode"].ToString();

                }

                DataTable dtBookingClassfare = dsFilghts.Tables["BookingClassFare"];
                if (dtBookingClassfare.Rows.Count > 0)
                {
                    DataRow[] rowBookingClassFare = dtBookingClassfare.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                    adultFare = rowBookingClassFare[0]["adultFare"].ToString();
                    if (dtBookingClassfare.Columns.Contains("childFare"))
                    {
                        childFare = rowBookingClassFare[0]["childFare"].ToString();
                    }
                    if (dtBookingClassfare.Columns.Contains("infantfare"))
                    {
                        infantfare = rowBookingClassFare[0]["infantfare"].ToString();
                    }
                    bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                    classType = rowBookingClassFare[0]["classType"].ToString();
                    farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                    Rule = rowBookingClassFare[0]["Rule"].ToString().Replace("<", "&lt;").Replace(">", "&gt;");
                    adultCommission = rowBookingClassFare[0]["adultCommission"].ToString();
                    childCommission = rowBookingClassFare[0]["childCommission"].ToString();
                    commissionOnTCharge = rowBookingClassFare[0]["commissionOnTCharge"].ToString();
                }

                #region ReturnOriginDestionOptionDetails

                DataTable dtFlightSegmentRet = dsFilghts.Tables["FlightSegment"];

                if (dtFlightSegmentRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentRet = dtFlightSegmentRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                    AirEquipTypeRet = rowFlightSegmentRet[0]["AirEquipType"].ToString();
                    ArrivalAirportCodeRet = rowFlightSegmentRet[0]["ArrivalAirportCode"].ToString();
                    ArrivalDateTimeRet = rowFlightSegmentRet[0]["ArrivalDateTime"].ToString();
                    DepartureAirportCodeRet = rowFlightSegmentRet[0]["DepartureAirportCode"].ToString();
                    DepartureDateTimeRet = rowFlightSegmentRet[0]["DepartureDateTime"].ToString();
                    FlightNumberRet = rowFlightSegmentRet[0]["FlightNumber"].ToString();
                    OperatingAirlineCodeRet = rowFlightSegmentRet[0]["OperatingAirlineCode"].ToString();
                    OperatingAirlineFlightNumberRet = rowFlightSegmentRet[0]["OperatingAirlineFlightNumber"].ToString();
                    RPHRet = rowFlightSegmentRet[0]["RPH"].ToString();
                    StopQuantityRet = rowFlightSegmentRet[0]["StopQuantity"].ToString();
                    airLineNameRet = rowFlightSegmentRet[0]["airLineName"].ToString();
                    airportTaxRet = rowFlightSegmentRet[0]["airportTax"].ToString();
                    imageFileNameRet = rowFlightSegmentRet[0]["imageFileName"].ToString();
                    DiscountRet = rowFlightSegmentRet[0]["Discount"].ToString();
                    airportTaxChildRet = rowFlightSegmentRet[0]["airportTaxChild"].ToString();
                    airportTaxInfantRet = rowFlightSegmentRet[0]["airportTaxInfant"].ToString();
                    adultTaxBreakupRet = rowFlightSegmentRet[0]["adultTaxBreakup"].ToString();
                    childTaxBreakupRet = rowFlightSegmentRet[0]["childTaxBreakup"].ToString();
                    infantTaxBreakupRet = rowFlightSegmentRet[0]["infantTaxBreakup"].ToString();

                    octaxRet = rowFlightSegmentRet[0]["octax"].ToString();
                    FlightSegmentsIDRet = rowFlightSegmentRet[0]["FlightSegments_Id"].ToString();
                }

                DataTable dtFlightSegmentsRet = dsFilghts.Tables["FlightSegments"];

                if (dtFlightSegmentsRet.Rows.Count > 0)
                {
                    DataRow[] rowFlightSegmentsRet = dtFlightSegmentsRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                    originDestination_IdRet = rowFlightSegmentsRet[0]["originDestinationoption_Id"].ToString();
                }
                DataTable dtoriginDestinationoptionRet = dsFilghts.Tables["originDestinationoption"];

                if (dtoriginDestinationoptionRet.Rows.Count > 0)
                {
                    DataRow[] roworiginDestinationoptionRet = dtoriginDestinationoptionRet.Select("originDestinationoption_Id=" + originDestination_IdRet);
                    idRet = roworiginDestinationoptionRet[0]["id"].ToString();
                    keyRet = roworiginDestinationoptionRet[0]["key"].ToString();
                }

                DataTable dtFareDetailsRet = dsFilghts.Tables["FareDetails"];

                if (dtFareDetailsRet.Rows.Count > 0)
                {
                    DataRow[] rowFareDetailsRet = dtFareDetailsRet.Select("originDestinationoption_Id=" + originDestination_IdRet);
                    fareDetailsIdRet = rowFareDetailsRet[0]["FareDetails_Id"].ToString();
                }

                DataTable dtChargeableFaresRet = dsFilghts.Tables["ChargeableFares"];
                if (dtChargeableFaresRet.Rows.Count > 0)
                {
                    DataRow[] rowChargeableFaresRet = dtChargeableFaresRet.Select("FareDetails_Id=" + fareDetailsIdRet);
                    actualBaseFareRet = rowChargeableFaresRet[0]["ActualBaseFare"].ToString();
                    taxRet = rowChargeableFaresRet[0]["tax"].ToString();
                    StaxRet = rowChargeableFaresRet[0]["Stax"].ToString();
                    SChargeRet = rowChargeableFaresRet[0]["SCharge"].ToString();
                    TDiscountRet = rowChargeableFaresRet[0]["TDiscount"].ToString();
                    TPartnerCommissionRet = rowChargeableFaresRet[0]["TPartnerCommission"].ToString();

                }

                DataTable dtNonChargeableFaresRet = dsFilghts.Tables["NonChargeableFares"];
                if (dtNonChargeableFaresRet.Rows.Count > 0)
                {
                    DataRow[] rowNonChargeableFaresRet = dtNonChargeableFaresRet.Select("FareDetails_Id=" + fareDetailsIdRet);
                    TChargeRet = rowNonChargeableFaresRet[0]["TCharge"].ToString();
                    TSdiscountRet = rowNonChargeableFaresRet[0]["TSdiscount"].ToString();
                    TMarkupRet = rowNonChargeableFaresRet[0]["TMarkup"].ToString();
                }
                DataTable dtBookingClassRet = dsFilghts.Tables["BookingClass"];
                if (dtBookingClassRet.Rows.Count > 0)
                {
                    DataRow[] rowBookingClassRet = dtBookingClassRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                    BookingClassAvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                    BookingClassResBookDesigCodeRet = rowBookingClassRet[0]["ResBookDesigCode"].ToString();

                }

                DataTable dtBookingClassfareRet = dsFilghts.Tables["BookingClassFare"];
                if (dtBookingClassfareRet.Rows.Count > 0)
                {
                    DataRow[] rowBookingClassFareRet = dtBookingClassfareRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                    adultFareRet = rowBookingClassFareRet[0]["adultFare"].ToString();
                    if (dtBookingClassfareRet.Columns.Contains("childFare"))
                    {
                        childFareRet = rowBookingClassFareRet[0]["childFare"].ToString();
                    }
                    if (dtBookingClassfareRet.Columns.Contains("infantfare"))
                    {
                        infantfareRet = rowBookingClassFareRet[0]["infantfare"].ToString();
                    }
                    bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                    classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                    farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                    RuleRet = rowBookingClassFareRet[0]["Rule"].ToString().Replace("<", "&lt;").Replace(">", "&gt;");
                    adultCommissionRet = rowBookingClassFareRet[0]["adultCommission"].ToString();
                    childCommissionRet = rowBookingClassFareRet[0]["childCommission"].ToString();
                    commissionOnTChargeRet = rowBookingClassFareRet[0]["commissionOnTCharge"].ToString();

                }

                // string flightBookingId = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();
                // Session["BookingID"] = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();
                string refNo = Common.GetFlightsReferenceNo("LJDF");
                Session["Order_Id"] = refNo.ToString();
                FlightBAL objFlightBal = new FlightBAL();

                objFlightBal.ReferenceNo = refNo;
                objFlightBal.TransId = string.Empty;
                objFlightBal.Status = "Pending";
                objFlightBal.AdultPax = Convert.ToInt32(ddlAdult.SelectedValue);
                objFlightBal.InfantPax = Convert.ToInt32(ddlInfant.SelectedValue);
                objFlightBal.ChildPax = Convert.ToInt32(ddlChild.SelectedValue);
                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.Scharge = Convert.ToDecimal(SCharge);
                objFlightBal.TDiscount = Convert.ToDecimal(TDiscount);
                objFlightBal.TPartnerCommission = Convert.ToDecimal(TPartnerCommission);
                objFlightBal.TCharge = Convert.ToDecimal(TCharge);
                objFlightBal.TMarkUp = Convert.ToDecimal(TMarkup);
                objFlightBal.TSDiscount = Convert.ToDecimal(TSdiscount);
                objFlightBal.ActualBasefareRet = Convert.ToDecimal(actualBaseFareRet);
                objFlightBal.TaxRet = Convert.ToDecimal(taxRet);
                objFlightBal.STaxRet = Convert.ToDecimal(StaxRet);
                objFlightBal.SchargeRet = Convert.ToDecimal(SChargeRet);
                objFlightBal.TDiscountRet = Convert.ToDecimal(TDiscountRet);
                objFlightBal.TPartnerCommissionRet = Convert.ToDecimal(TPartnerCommissionRet);
                objFlightBal.TChargeRet = Convert.ToDecimal(TChargeRet);
                objFlightBal.TMarkUpRet = Convert.ToDecimal(TMarkupRet);
                objFlightBal.TSDiscountRet = Convert.ToDecimal(TSdiscountRet);
                string givenName = string.Empty;
                string surName = string.Empty;
                string namereference = string.Empty;
                string psgrType = string.Empty;
                string Age = string.Empty;
                string customerInfo = string.Empty;
                #region customer

                Table tbladults1 = (Table)this.UpdatePanel1.FindControl("tblAdults");
                for (int l = 1; l <= Convert.ToInt32(Session["adultcnt"]); l++)
                {

                    TextBox txtFn = (TextBox)tbladults1.FindControl("txtFn" + l);
                    TextBox txtLn = (TextBox)tbladults1.FindControl("txtLn" + l);
                    DropDownList ddlTitle = (DropDownList)tbladults1.FindControl("ddlTitle" + 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 tblChild1 = (Table)this.UpdatePanel1.FindControl("tblChild");
                for (int j = 1; j <= Convert.ToInt32(Session["childCnt"]); j++)
                {
                    TextBox txtFn = (TextBox)tblChild1.FindControl("txtCFn" + j);

                    TextBox txtLn = (TextBox)tblChild1.FindControl("txtCLn" + j);

                    DropDownList ddlTitle = (DropDownList)tblChild1.FindControl("ddlCTitle" + j);

                    TextBox txtBirthDate = (TextBox)tblChild1.FindControl("txtCBirthDate" + 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.ToString();
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "Chd" + "|" + age + "|" + txtBirthDate.Text.ToString();
                    }
                    //  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 tblInfants1 = (Table)this.UpdatePanel1.FindControl("tblInfants");
                for (int k = 1; k <= Convert.ToInt32(Session["infantCnt"]); k++)
                {
                    TextBox txtFn = (TextBox)tblInfants1.FindControl("txtIFn" + k);

                    TextBox txtLn = (TextBox)tblInfants1.FindControl("txtILn" + k);

                    DropDownList ddlTitle = (DropDownList)tblInfants1.FindControl("ddlITitle" + k);

                    TextBox txtBirthDate = (TextBox)tblInfants1.FindControl("txtIBirthDate" + 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.ToString();
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "Inf" + "|" + age + "|" + txtBirthDate.Text.ToString();
                    }
                    //  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>";
                }
                #endregion
                objFlightBal.Address = txtCity.Text + "," + txtState.Text + "," + ddlcountry.SelectedValue + "," + txtPostalCode.Text + ",";
                objFlightBal.Customer_Details = customerInfo;
                //objFlightBal.Customer_Details = "Mr.|rajini|reguri|Adt|";
                objFlightBal.telephone = txtMobileNum.Text;
                objFlightBal.emailAddress = lblEmailAddress.Text = txtEmailID.Text;
                objFlightBal.TripMode = "Round";
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                if (Session["Role"] == null)
                {
                    objFlightBal.Type = "Guest";
                }
                else
                {
                    objFlightBal.Type = Session["Role"].ToString();
                }
                objFlightBal.id = id;
                objFlightBal.key = key;
                objFlightBal.idRet = idRet;
                objFlightBal.keyRet = keyRet;
                DataTable dtflightBookingId = objFlightBal.AddDomesticFlightBooking(objFlightBal);

                string flightBookingId = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();
                Session["BookingID"] = dtflightBookingId.Rows[0]["FlightBookingID"].ToString();

                objFlightBal.FlightBookingID = flightBookingId.ToString();
                objFlightBal.AirEquipType = AirEquipType;
                objFlightBal.ArrivalAirportCode = ArrivalAirportCode;
                objFlightBal.ArrivalDateTime = ArrivalDateTime;
                objFlightBal.DepartureAirportCode = DepartureAirportCode;
                objFlightBal.DepartureDateTime = DepartureDateTime;
                objFlightBal.FlightNumber = FlightNumber;
                objFlightBal.OperatingAirlineCode = OperatingAirlineCode;
                objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumber;
                objFlightBal.RPH = RPH;
                objFlightBal.StopQuantity = StopQuantity;
                objFlightBal.airlineName = airLineName;
                objFlightBal.airportTax = airportTax;
                objFlightBal.imageFileName = imageFileName;
                objFlightBal.Discount = Discount;
                objFlightBal.airportTaxChild = airportTaxChild;
                objFlightBal.airportTaxInfant = airportTaxInfant;
                objFlightBal.adultTaxBreakUp = adultTaxBreakup;
                objFlightBal.ChildTaxBreakUp = childTaxBreakup;
                objFlightBal.InfantTaxBreakUp = infantTaxBreakup;
                objFlightBal.ocTax = octax;
                objFlightBal.Availability = BookingClassAvailability;
                objFlightBal.ResBookingCode = BookingClassResBookDesigCode;
                objFlightBal.adultFare = adultFare;
                objFlightBal.bookingClass = bookingclass;
                objFlightBal.ChildFare = childFare;
                objFlightBal.ClassType = classType;
                objFlightBal.farebasisCode = farebasiscode;
                objFlightBal.infantFare = infantfare;
                objFlightBal.Fare_Rule = Rule;
                objFlightBal.adultCommission = adultCommission;
                objFlightBal.childCommission = childCommission;
                objFlightBal.CommissionOnTCharge = commissionOnTCharge;
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);

                bool res = objFlightBal.AddDomesticFlightBookingsegments(objFlightBal);

                objFlightBal.FlightBookingID = flightBookingId.ToString();
                objFlightBal.AirEquipType = AirEquipTypeRet;
                objFlightBal.ArrivalAirportCode = ArrivalAirportCodeRet;
                objFlightBal.ArrivalDateTime = ArrivalDateTimeRet;
                objFlightBal.DepartureAirportCode = DepartureAirportCodeRet;
                objFlightBal.DepartureDateTime = DepartureDateTimeRet;
                objFlightBal.FlightNumber = FlightNumberRet;
                objFlightBal.OperatingAirlineCode = OperatingAirlineCodeRet;
                objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumberRet;
                objFlightBal.RPH = RPHRet;
                objFlightBal.StopQuantity = StopQuantityRet;
                objFlightBal.airlineName = airLineNameRet;
                objFlightBal.airportTax = airportTaxRet;
                objFlightBal.imageFileName = imageFileNameRet;
                objFlightBal.Discount = DiscountRet;
                objFlightBal.airportTaxChild = airportTaxChildRet;
                objFlightBal.airportTaxInfant = airportTaxInfantRet;
                objFlightBal.adultTaxBreakUp = adultTaxBreakupRet;
                objFlightBal.ChildTaxBreakUp = childTaxBreakupRet;
                objFlightBal.InfantTaxBreakUp = infantTaxBreakupRet;
                objFlightBal.ocTax = octaxRet;
                objFlightBal.Availability = BookingClassAvailabilityRet;
                objFlightBal.ResBookingCode = BookingClassResBookDesigCodeRet;
                objFlightBal.adultFare = adultFareRet;
                objFlightBal.bookingClass = bookingclassRet;
                objFlightBal.ChildFare = childFareRet;
                objFlightBal.ClassType = classTypeRet;
                objFlightBal.farebasisCode = farebasiscodeRet;
                objFlightBal.infantFare = infantfareRet;
                objFlightBal.Fare_Rule = RuleRet;
                objFlightBal.adultCommission = adultCommissionRet;
                objFlightBal.childCommission = childCommissionRet;
                objFlightBal.CommissionOnTCharge = commissionOnTChargeRet;
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);

                res = objFlightBal.AddDomesticFlightBookingsegments(objFlightBal);

                if (res)
                {
                    try
                    {

                        //  Response.Redirect("~/pay.aspx?val=Dom", false);
                        #region Checking the roles and booking the tickets

                        TotalFare = (Convert.ToDouble(lblTotalAmtreturn) + Convert.ToDouble(lblTotalAmt)).ToString();
                        Session["Amount"] = TotalFare;
                          if (Session["Role"] == null)
                        {
                            Response.Redirect("~/pay.aspx?val=Dom", false);
                        }
                          else if (Session["Role"].ToString() == "User")
                        {
                            objBAL = new ClsBAL();
                            DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                            Session["AgentId_Agent"] = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

                            Response.Redirect("~/pay.aspx?val=Dom", false);
                        }
                        else if (Session["Role"].ToString() == "Admin")
                        {
                            saveround(sender, e);
                        }
                        else if (Session["Role"].ToString() == "Agent")
                        {
                            DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                            DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "DomesticFlights", airLineName.ToString()); // 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 agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();
                            TotalFare = (Convert.ToDouble(lblTotalAmtreturn.Text) + Convert.ToDouble(lblTotalAmt.Text)).ToString();
                            string actualFare = TotalFare;
                            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))
                            {
                                saveround(sender, e);
                            }
                            else
                            {
                                mp3.Show();

                                lblerror.Text = "Your balance is too low to book the ticket.So,please contact administrator";

                                return;
                            }
                        }
                        else if (Session["Role"].ToString() == "Distributor")
                        {
                            DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                            DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "DomesticFlights", airLineName.ToString()); // 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 agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();
                            TotalFare = (Convert.ToDouble(lblTotalAmtreturn.Text) + Convert.ToDouble(lblTotalAmt.Text)).ToString();
                            string actualFare = TotalFare;
                            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))
                            {
                                saveround(sender, e);
                            }
                            else
                            {
                                mp3.Show();

                                lblerror.Text = "Your balance is too low to book the ticket.So, please contact administrator";

                                return;
                            }
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        //  LogError("frmSearchBus.aspx", "paymentgateway", DateTime.Now, ex.Message.ToString());
                        // lblMsg1.Visible = true;
                        // lblMsg1.Text = "Error in the payment gateway";
                    }
                }
                #endregion
            }
            catch (NullReferenceException)
            {
                Response.Redirect("~/Default.aspx", false);
            }
        }
        catch (Exception ex)
        {
            mp3.Show();
            lblerror.Text = ex.Message;
        }
    }
コード例 #2
0
    protected void btnRoundTripSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["UserID"] == null) { Response.Redirect("~/Default.aspx", false); return; }

            #region Variables
            string FlightSegmentsID = string.Empty;
            string originDestination_Id = string.Empty;
            string fareDetailsId = string.Empty;
            string TotalFare = string.Empty;
            string AirEquipType = string.Empty;
            string ArrivalAirportCode = string.Empty;
            string ArrivalDateTime = string.Empty;
            string DepartureAirportCode = string.Empty;
            string DepartureDateTime = string.Empty;
            string FlightNumber = string.Empty;
            string OperatingAirlineCode = string.Empty;
            string OperatingAirlineFlightNumber = string.Empty;
            string RPH = string.Empty;
            string StopQuantity = string.Empty;
            string airLineName = string.Empty;
            string airportTax = string.Empty;
            string imageFileName = string.Empty;
            string BookingClassAvailability = string.Empty;
            string BookingClassResBookDesigCode = string.Empty;
            string adultFare = string.Empty;
            string bookingclass = string.Empty;
            string childFare = string.Empty;
            string classType = string.Empty;
            string farebasiscode = string.Empty;
            string infantfare = string.Empty;
            string Rule = string.Empty;
            string adultCommission = string.Empty;
            string childCommission = string.Empty;
            string commissionOnTCharge = string.Empty;
            string Discount = string.Empty;
            string airportTaxChild = string.Empty;
            string airportTaxInfant = string.Empty;
            string adultTaxBreakup = string.Empty;
            string childTaxBreakup = string.Empty;
            string infantTaxBreakup = string.Empty;
            string octax = string.Empty;
            string id = string.Empty;
            string key = string.Empty;
            string TCharge = string.Empty;
            string TMarkup = string.Empty;
            string TSdiscount = string.Empty;
            string TPartnerCommission = string.Empty;
            string actualBaseFare = string.Empty;
            string tax = string.Empty;
            string Stax = string.Empty;
            string SCharge = string.Empty;
            string TDiscount = string.Empty;

            string responseDepartId = string.Empty;
            string responseReturnId = string.Empty;
            string OriginDestinationOptionsId = string.Empty;

            string FlightSegmentsIDRet = string.Empty;
            string originDestination_IdRet = string.Empty;
            string fareDetailsIdRet = string.Empty;
            string TotalFareRet = string.Empty;
            string AirEquipTypeRet = string.Empty;
            string ArrivalAirportCodeRet = string.Empty;
            string ArrivalDateTimeRet = string.Empty;
            string DepartureAirportCodeRet = string.Empty;
            string DepartureDateTimeRet = string.Empty;
            string FlightNumberRet = string.Empty;
            string OperatingAirlineCodeRet = string.Empty;
            string OperatingAirlineFlightNumberRet = string.Empty;
            string RPHRet = string.Empty;
            string StopQuantityRet = string.Empty;
            string airLineNameRet = string.Empty;
            string airportTaxRet = string.Empty;
            string imageFileNameRet = string.Empty;
            string BookingClassAvailabilityRet = string.Empty;
            string BookingClassResBookDesigCodeRet = string.Empty;
            string adultFareRet = string.Empty;
            string bookingclassRet = string.Empty;
            string childFareRet = string.Empty;
            string classTypeRet = string.Empty;
            string farebasiscodeRet = string.Empty;
            string infantfareRet = string.Empty;
            string RuleRet = string.Empty;
            string adultCommissionRet = string.Empty;
            string childCommissionRet = string.Empty;
            string commissionOnTChargeRet = string.Empty;
            string DiscountRet = string.Empty;
            string airportTaxChildRet = string.Empty;
            string airportTaxInfantRet = string.Empty;
            string adultTaxBreakupRet = string.Empty;
            string childTaxBreakupRet = string.Empty;
            string infantTaxBreakupRet = string.Empty;
            string octaxRet = string.Empty;
            string idRet = string.Empty;
            string keyRet = string.Empty;
            string TChargeRet = string.Empty;
            string TMarkupRet = string.Empty;
            string TSdiscountRet = string.Empty;
            string TPartnerCommissionRet = string.Empty;
            string actualBaseFareRet = string.Empty;
            string taxRet = string.Empty;
            string StaxRet = string.Empty;
            string SChargeRet = string.Empty;
            string TDiscountRet = string.Empty;

            string responseDepartIdRet = string.Empty;
            string responseReturnIdRet = string.Empty;
            string OriginDestinationOptionsIdRet = string.Empty;

            #endregion

            DataTable dtFlightSegment = dsFilghts.Tables["FlightSegment"];

            if (dtFlightSegment.Rows.Count > 0)
            {
                DataRow[] rowFlightSegment = dtFlightSegment.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                AirEquipType = rowFlightSegment[0]["AirEquipType"].ToString();
                ArrivalAirportCode = rowFlightSegment[0]["ArrivalAirportCode"].ToString();
                ArrivalDateTime = rowFlightSegment[0]["ArrivalDateTime"].ToString();
                DepartureAirportCode = rowFlightSegment[0]["DepartureAirportCode"].ToString();
                DepartureDateTime = rowFlightSegment[0]["DepartureDateTime"].ToString();
                FlightNumber = rowFlightSegment[0]["FlightNumber"].ToString();
                OperatingAirlineCode = rowFlightSegment[0]["OperatingAirlineCode"].ToString();
                OperatingAirlineFlightNumber = rowFlightSegment[0]["OperatingAirlineFlightNumber"].ToString();
                RPH = rowFlightSegment[0]["RPH"].ToString();
                StopQuantity = rowFlightSegment[0]["StopQuantity"].ToString();
                airLineName = rowFlightSegment[0]["airLineName"].ToString();
                airportTax = rowFlightSegment[0]["airportTax"].ToString();
                imageFileName = rowFlightSegment[0]["imageFileName"].ToString();
                Discount = rowFlightSegment[0]["Discount"].ToString();
                airportTaxChild = rowFlightSegment[0]["airportTaxChild"].ToString();
                airportTaxInfant = rowFlightSegment[0]["airportTaxInfant"].ToString();
                adultTaxBreakup = rowFlightSegment[0]["adultTaxBreakup"].ToString();
                childTaxBreakup = rowFlightSegment[0]["childTaxBreakup"].ToString();
                infantTaxBreakup = rowFlightSegment[0]["infantTaxBreakup"].ToString();
                octax = rowFlightSegment[0]["octax"].ToString();
                FlightSegmentsID = rowFlightSegment[0]["FlightSegments_Id"].ToString();
            }

            DataTable dtFlightSegments = dsFilghts.Tables["FlightSegments"];

            if (dtFlightSegments.Rows.Count > 0)
            {
                DataRow[] rowFlightSegments = dtFlightSegments.Select("FlightSegments_Id=" + FlightSegmentsID);
                originDestination_Id = rowFlightSegments[0]["originDestinationoption_Id"].ToString();
            }
            DataTable dtoriginDestinationoption = dsFilghts.Tables["originDestinationoption"];

            if (dtoriginDestinationoption.Rows.Count > 0)
            {
                DataRow[] roworiginDestinationoption = dtoriginDestinationoption.Select("originDestinationoption_Id=" + originDestination_Id);
                id = roworiginDestinationoption[0]["id"].ToString();
                key = roworiginDestinationoption[0]["key"].ToString();
            }

            DataTable dtFareDetails = dsFilghts.Tables["FareDetails"];

            if (dtFareDetails.Rows.Count > 0)
            {
                DataRow[] rowFareDetails = dtFareDetails.Select("originDestinationoption_Id=" + originDestination_Id);
                fareDetailsId = rowFareDetails[0]["FareDetails_Id"].ToString();
            }

            DataTable dtChargeableFares = dsFilghts.Tables["ChargeableFares"];
            if (dtChargeableFares.Rows.Count > 0)
            {
                DataRow[] rowChargeableFares = dtChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                actualBaseFare = rowChargeableFares[0]["ActualBaseFare"].ToString();
                tax = rowChargeableFares[0]["tax"].ToString();
                Stax = rowChargeableFares[0]["Stax"].ToString();
                SCharge = rowChargeableFares[0]["SCharge"].ToString();
                TDiscount = rowChargeableFares[0]["TDiscount"].ToString();
                TPartnerCommission = rowChargeableFares[0]["TPartnerCommission"].ToString();

            }

            DataTable dtNonChargeableFares = dsFilghts.Tables["NonChargeableFares"];
            if (dtNonChargeableFares.Rows.Count > 0)
            {
                DataRow[] rowNonChargeableFares = dtNonChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                TCharge = rowNonChargeableFares[0]["TCharge"].ToString();
                TSdiscount = rowNonChargeableFares[0]["TSdiscount"].ToString();
                TMarkup = rowNonChargeableFares[0]["TMarkup"].ToString();
            }
            DataTable dtBookingClass = dsFilghts.Tables["BookingClass"];
            if (dtBookingClass.Rows.Count > 0)
            {
                DataRow[] rowBookingClass = dtBookingClass.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                BookingClassAvailability = rowBookingClass[0]["Availability"].ToString();
                BookingClassResBookDesigCode = rowBookingClass[0]["ResBookDesigCode"].ToString();

            }

            DataTable dtBookingClassfare = dsFilghts.Tables["BookingClassFare"];
            if (dtBookingClassfare.Rows.Count > 0)
            {
                DataRow[] rowBookingClassFare = dtBookingClassfare.Select("FlightSegment_Id=" + lblonwardFlightSegmentId.Text);
                adultFare = rowBookingClassFare[0]["adultFare"].ToString();
                if (dtBookingClassfare.Columns.Contains("childFare"))
                {
                    childFare = rowBookingClassFare[0]["childFare"].ToString();
                }
                if (dtBookingClassfare.Columns.Contains("infantfare"))
                {
                    infantfare = rowBookingClassFare[0]["infantfare"].ToString();
                }
                bookingclass = rowBookingClassFare[0]["bookingclass"].ToString();
                classType = rowBookingClassFare[0]["classType"].ToString();
                farebasiscode = rowBookingClassFare[0]["farebasiscode"].ToString();
                Rule = rowBookingClassFare[0]["Rule"].ToString().Replace("<", "&lt;").Replace(">", "&gt;");
                adultCommission = rowBookingClassFare[0]["adultCommission"].ToString();
                childCommission = rowBookingClassFare[0]["childCommission"].ToString();
                commissionOnTCharge = rowBookingClassFare[0]["commissionOnTCharge"].ToString();
            }

            #region ReturnOriginDestionOptionDetails
            DataTable dtFlightSegmentRet = dsFilghts.Tables["FlightSegment"];

            if (dtFlightSegmentRet.Rows.Count > 0)
            {
                DataRow[] rowFlightSegmentRet = dtFlightSegmentRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                AirEquipTypeRet = rowFlightSegmentRet[0]["AirEquipType"].ToString();
                ArrivalAirportCodeRet = rowFlightSegmentRet[0]["ArrivalAirportCode"].ToString();
                ArrivalDateTimeRet = rowFlightSegmentRet[0]["ArrivalDateTime"].ToString();
                DepartureAirportCodeRet = rowFlightSegmentRet[0]["DepartureAirportCode"].ToString();
                DepartureDateTimeRet = rowFlightSegmentRet[0]["DepartureDateTime"].ToString();
                FlightNumberRet = rowFlightSegmentRet[0]["FlightNumber"].ToString();
                OperatingAirlineCodeRet = rowFlightSegmentRet[0]["OperatingAirlineCode"].ToString();
                OperatingAirlineFlightNumberRet = rowFlightSegmentRet[0]["OperatingAirlineFlightNumber"].ToString();
                RPHRet = rowFlightSegmentRet[0]["RPH"].ToString();
                StopQuantityRet = rowFlightSegmentRet[0]["StopQuantity"].ToString();
                airLineNameRet = rowFlightSegmentRet[0]["airLineName"].ToString();
                airportTaxRet = rowFlightSegmentRet[0]["airportTax"].ToString();
                imageFileNameRet = rowFlightSegmentRet[0]["imageFileName"].ToString();
                DiscountRet = rowFlightSegmentRet[0]["Discount"].ToString();
                airportTaxChildRet = rowFlightSegmentRet[0]["airportTaxChild"].ToString();
                airportTaxInfantRet = rowFlightSegmentRet[0]["airportTaxInfant"].ToString();
                adultTaxBreakupRet = rowFlightSegmentRet[0]["adultTaxBreakup"].ToString();
                childTaxBreakupRet = rowFlightSegmentRet[0]["childTaxBreakup"].ToString();
                infantTaxBreakupRet = rowFlightSegmentRet[0]["infantTaxBreakup"].ToString();

                octaxRet = rowFlightSegmentRet[0]["octax"].ToString();
                FlightSegmentsIDRet = rowFlightSegmentRet[0]["FlightSegments_Id"].ToString();
            }

            DataTable dtFlightSegmentsRet = dsFilghts.Tables["FlightSegments"];

            if (dtFlightSegmentsRet.Rows.Count > 0)
            {
                DataRow[] rowFlightSegmentsRet = dtFlightSegmentsRet.Select("FlightSegments_Id=" + FlightSegmentsIDRet);
                originDestination_IdRet = rowFlightSegmentsRet[0]["originDestinationoption_Id"].ToString();
            }
            DataTable dtoriginDestinationoptionRet = dsFilghts.Tables["originDestinationoption"];

            if (dtoriginDestinationoptionRet.Rows.Count > 0)
            {
                DataRow[] roworiginDestinationoptionRet = dtoriginDestinationoptionRet.Select("originDestinationoption_Id=" + originDestination_IdRet);
                idRet = roworiginDestinationoptionRet[0]["id"].ToString();
                keyRet = roworiginDestinationoptionRet[0]["key"].ToString();
            }

            DataTable dtFareDetailsRet = dsFilghts.Tables["FareDetails"];

            if (dtFareDetailsRet.Rows.Count > 0)
            {
                DataRow[] rowFareDetailsRet = dtFareDetailsRet.Select("originDestinationoption_Id=" + originDestination_IdRet);
                fareDetailsIdRet = rowFareDetailsRet[0]["FareDetails_Id"].ToString();
            }

            DataTable dtChargeableFaresRet = dsFilghts.Tables["ChargeableFares"];
            if (dtChargeableFaresRet.Rows.Count > 0)
            {
                DataRow[] rowChargeableFaresRet = dtChargeableFaresRet.Select("FareDetails_Id=" + fareDetailsIdRet);
                actualBaseFareRet = rowChargeableFaresRet[0]["ActualBaseFare"].ToString();
                taxRet = rowChargeableFaresRet[0]["tax"].ToString();
                StaxRet = rowChargeableFaresRet[0]["Stax"].ToString();
                SChargeRet = rowChargeableFaresRet[0]["SCharge"].ToString();
                TDiscountRet = rowChargeableFaresRet[0]["TDiscount"].ToString();
                TPartnerCommissionRet = rowChargeableFaresRet[0]["TPartnerCommission"].ToString();

            }

            DataTable dtNonChargeableFaresRet = dsFilghts.Tables["NonChargeableFares"];
            if (dtNonChargeableFaresRet.Rows.Count > 0)
            {
                DataRow[] rowNonChargeableFaresRet = dtNonChargeableFaresRet.Select("FareDetails_Id=" + fareDetailsIdRet);
                TChargeRet = rowNonChargeableFaresRet[0]["TCharge"].ToString();
                TSdiscountRet = rowNonChargeableFaresRet[0]["TSdiscount"].ToString();
                TMarkupRet = rowNonChargeableFaresRet[0]["TMarkup"].ToString();
            }
            DataTable dtBookingClassRet = dsFilghts.Tables["BookingClass"];
            if (dtBookingClassRet.Rows.Count > 0)
            {
                DataRow[] rowBookingClassRet = dtBookingClassRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                BookingClassAvailabilityRet = rowBookingClassRet[0]["Availability"].ToString();
                BookingClassResBookDesigCodeRet = rowBookingClassRet[0]["ResBookDesigCode"].ToString();

            }

            DataTable dtBookingClassfareRet = dsFilghts.Tables["BookingClassFare"];
            if (dtBookingClassfareRet.Rows.Count > 0)
            {
                DataRow[] rowBookingClassFareRet = dtBookingClassfareRet.Select("FlightSegment_Id=" + lblReturnFlightSegment.Text);
                adultFareRet = rowBookingClassFareRet[0]["adultFare"].ToString();
                if (dtBookingClassfareRet.Columns.Contains("childFare"))
                {
                    childFareRet = rowBookingClassFareRet[0]["childFare"].ToString();
                }
                if (dtBookingClassfareRet.Columns.Contains("infantfare"))
                {
                    infantfareRet = rowBookingClassFareRet[0]["infantfare"].ToString();
                }
                bookingclassRet = rowBookingClassFareRet[0]["bookingclass"].ToString();
                classTypeRet = rowBookingClassFareRet[0]["classType"].ToString();
                farebasiscodeRet = rowBookingClassFareRet[0]["farebasiscode"].ToString();
                RuleRet = rowBookingClassFareRet[0]["Rule"].ToString().Replace("<", "&lt;").Replace(">", "&gt;");
                adultCommissionRet = rowBookingClassFareRet[0]["adultCommission"].ToString();
                childCommissionRet = rowBookingClassFareRet[0]["childCommission"].ToString();
                commissionOnTChargeRet = rowBookingClassFareRet[0]["commissionOnTCharge"].ToString();

            }

            #endregion
            #region Pricing

            #region Pricing

            String XMLPricing = "<pricingrequest><onwardFlights><OriginDestinationOption><FareDetails><ChargeableFares><ActualBaseFare>" + actualBaseFare + "</ActualBaseFare><Tax>" + tax + "</Tax> <STax>" + Stax + "</STax><SCharge>" + SCharge + "</SCharge> <TDiscount>" + TDiscount + "</TDiscount><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TCharge + "</TCharge> <TMarkup>" + TMarkup + "</TMarkup><TSdiscount>" + TDiscount + "</TSdiscount> </NonchargeableFares></FareDetails> <FlightSegments> <FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><RPH>" + RPH + "</RPH> <StopQuantity>" + StopQuantity + "</StopQuantity><airLineName>" + airLineName + "</airLineName><airportTax>" + airportTax + "</airportTax><imageFileName>" + imageFileName + "</imageFileName> <BookingClass><Availability>" + BookingClassAvailability + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCode + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFare + "</adultFare><bookingclass>" + bookingclass + "</bookingclass> <childFare>" + childFare + "</childFare><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><infantfare>" + infantfare + "</infantfare> <Rule>" + Rule + "</Rule><adultCommission>" + adultCommission + "</adultCommission><childCommission>" + childCommission + "</childCommission><commissionOnTCharge>" + commissionOnTCharge + "</commissionOnTCharge></BookingClassFare> <Discount>" + Discount + "</Discount><airportTaxChild>" + airportTaxChild + "</airportTaxChild><airportTaxInfant>" + airportTaxInfant + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakup + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakup + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakup + "</infantTaxBreakup><octax>" + octax + "</octax> </FlightSegment> </FlightSegments><id>" + id + "</id><key>" + key + "</key> </OriginDestinationOption></onwardFlights>";

            XMLPricing = XMLPricing + "<returnFlights><OriginDestinationOption><FareDetails><ChargeableFares><ActualBaseFare>" + actualBaseFareRet + "</ActualBaseFare><Tax>" + taxRet + "</Tax> <STax>" + StaxRet + "</STax><SCharge>" + SChargeRet + "</SCharge> <TDiscount>" + TDiscountRet + "</TDiscount><TPartnerCommission>" + TPartnerCommissionRet + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TChargeRet + "</TCharge> <TMarkup>" + TMarkupRet + "</TMarkup><TSdiscount>" + TDiscountRet + "</TSdiscount> </NonchargeableFares></FareDetails> <FlightSegments> <FlightSegment><AirEquipType>" + AirEquipTypeRet + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCodeRet + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTimeRet + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCodeRet + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTimeRet + "</DepartureDateTime><FlightNumber>" + FlightNumberRet + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCodeRet + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumberRet + "</OperatingAirlineFlightNumber><RPH>" + RPHRet + "</RPH> <StopQuantity>" + StopQuantityRet + "</StopQuantity><airLineName>" + airLineNameRet + "</airLineName><airportTax>" + airportTaxRet + "</airportTax><imageFileName>" + imageFileNameRet + "</imageFileName> <BookingClass><Availability>" + BookingClassAvailabilityRet + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCodeRet + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFareRet + "</adultFare><bookingclass>" + bookingclassRet + "</bookingclass> <childFare>" + childFareRet + "</childFare><classType>" + classTypeRet + "</classType><farebasiscode>" + farebasiscodeRet + "</farebasiscode><infantfare>" + infantfareRet + "</infantfare> <Rule>" + RuleRet + "</Rule><adultCommission>" + adultCommissionRet + "</adultCommission><childCommission>" + childCommissionRet + "</childCommission><commissionOnTCharge>" + commissionOnTChargeRet + "</commissionOnTCharge></BookingClassFare> <Discount>" + DiscountRet + "</Discount><airportTaxChild>" + airportTaxChildRet + "</airportTaxChild><airportTaxInfant>" + airportTaxInfantRet + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakupRet + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakupRet + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakupRet + "</infantTaxBreakup><octax>" + octaxRet + "</octax> </FlightSegment> </FlightSegments><id>" + idRet + "</id><key>" + keyRet + "</key> </OriginDestinationOption></returnFlights>";

            XMLPricing = XMLPricing + "<telePhone>" + txtPhoneNum.Text + "</telePhone><email>" + txtEmailID.Text + "</email> <creditcardno></creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" +  Session["adultcnt"].ToString() + "</AdultPax><ChildPax>" +  Session["childCnt"].ToString() + "</ChildPax><InfantPax>" + Session["infantCnt"].ToString() + "</InfantPax></pricingrequest>";

            DataSet dsFlightPricing = objFlights.GetPricingDetails(XMLPricing.Replace("<br>",""));

            if (!dsFlightPricing.Tables[0].Columns.Contains("error"))
            {
                string ReturnFlightId = dsFlightPricing.Tables["returnFlights"].Rows[0]["ReturnFlights_Id"].ToString();

                DataTable dtchangeFlightSegments = dsFlightPricing.Tables["originDestinationoption"];
                if (dtchangeFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowchangeFilghtSegments = dtchangeFlightSegments.Select("ReturnFlights_Id=" + ReturnFlightId);
                    originDestination_IdRet = rowchangeFilghtSegments[0]["OriginDestinationOption_Id"].ToString();
                }

                DataTable dtchangeFareDetails = dsFlightPricing.Tables[3];
                if (dtchangeFareDetails.Rows.Count > 0)
                {
                    DataRow[] rowchangeFareDetails = dtchangeFareDetails.Select("OriginDestinationOption_Id=" + originDestination_IdRet);
                    fareDetailsIdRet = rowchangeFareDetails[0]["FareDetails_Id"].ToString();
                }

                DataTable dtchangeprice = dsFlightPricing.Tables[4];
                if (dtchangeprice.Rows.Count > 0)
                {
                    DataRow[] rowchangeprices = dtchangeprice.Select("FareDetails_Id=" + fareDetailsIdRet);
                    TPartnerCommissionRet = rowchangeprices[0]["TPartnerCommission"].ToString();
                    actualBaseFareRet = rowchangeprices[0]["ActualBaseFare"].ToString();
                    taxRet = rowchangeprices[0]["Tax"].ToString();
                    StaxRet = rowchangeprices[0]["Stax"].ToString();
                    SChargeRet = rowchangeprices[0]["SCharge"].ToString();
                    TDiscountRet = rowchangeprices[0]["TDiscount"].ToString();
                    TotalFare = (Convert.ToDecimal(actualBaseFare) + Convert.ToDecimal(tax) + Convert.ToDecimal(Stax).ToString()) ;//+ Convert.ToDecimal(SCharge) - Convert.ToDecimal(TDiscount)).ToString();
                }
            }

            #endregion

            #endregion

            string refNo = Common.GetFlightsReferenceNo("LJDF");

            String xmlRequestData = "<Bookingrequest><onwardFlights><OriginDestinationOption><FareDetails> <ChargeableFares><ActualBaseFare>" + actualBaseFare + "</ActualBaseFare> <Tax>" + tax + "</Tax><STax>" + Stax + "</STax> <SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TCharge + "</TCharge> <TMarkup>" + TMarkup + "</TMarkup><TSdiscount>" + TSdiscount + "</TSdiscount> </NonchargeableFares></FareDetails>";
            xmlRequestData = xmlRequestData + "<FlightSegments> <FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><RPH>" + RPH + "</RPH> <StopQuantity>" + StopQuantity + "</StopQuantity><airLineName>" + airLineName + "</airLineName><airportTax>" + airportTax + "</airportTax><imageFileName>" + imageFileName + "</imageFileName>";
            xmlRequestData = xmlRequestData + "<BookingClass><Availability>" + BookingClassAvailability + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCode + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFare + "</adultFare><bookingclass>" + bookingclass + "</bookingclass> <childFare>" + childFare + "</childFare><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><infantfare>" + infantfare + "</infantfare> <Rule>" + Rule + "</Rule><adultCommission>" + adultCommission + "</adultCommission><childCommission>" + childCommission + "</childCommission><commissionOnTCharge>" + commissionOnTCharge + "</commissionOnTCharge></BookingClassFare>";
            xmlRequestData = xmlRequestData + "<Discount>" + Discount + "</Discount><airportTaxChild>" + airportTaxChild + "</airportTaxChild><airportTaxInfant>" + airportTaxInfant + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakup + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakup + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakup + "</infantTaxBreakup><octax>" + octax + "</octax> </FlightSegment> </FlightSegments>";
            xmlRequestData = xmlRequestData + "<id>" + id + "</id><key>" + key + "</key> </OriginDestinationOption></onwardFlights>";

            xmlRequestData = xmlRequestData + "<returnFlights><OriginDestinationOption><FareDetails> <ChargeableFares><ActualBaseFare>" + actualBaseFareRet + "</ActualBaseFare> <Tax>" + taxRet + "</Tax><STax>" + StaxRet + "</STax> <SCharge>" + SChargeRet + "</SCharge><TDiscount>" + TDiscountRet + "</TDiscount><TPartnerCommission>" + TPartnerCommissionRet + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TChargeRet + "</TCharge> <TMarkup>" + TMarkupRet + "</TMarkup><TSdiscount>" + TSdiscountRet + "</TSdiscount> </NonchargeableFares></FareDetails>";
            xmlRequestData = xmlRequestData + "<FlightSegments> <FlightSegment><AirEquipType>" + AirEquipTypeRet + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCodeRet + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTimeRet + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCodeRet + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTimeRet + "</DepartureDateTime><FlightNumber>" + FlightNumberRet + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCodeRet + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumberRet + "</OperatingAirlineFlightNumber><RPH>" + RPHRet + "</RPH> <StopQuantity>" + StopQuantityRet + "</StopQuantity><airLineName>" + airLineNameRet + "</airLineName><airportTax>" + airportTaxRet + "</airportTax><imageFileName>" + imageFileNameRet + "</imageFileName>";
            xmlRequestData = xmlRequestData + "<BookingClass><Availability>" + BookingClassAvailabilityRet + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCodeRet + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFareRet + "</adultFare><bookingclass>" + bookingclassRet + "</bookingclass> <childFare>" + childFareRet + "</childFare><classType>" + classTypeRet + "</classType><farebasiscode>" + farebasiscodeRet + "</farebasiscode><infantfare>" + infantfareRet + "</infantfare> <Rule>" + RuleRet + "</Rule><adultCommission>" + adultCommissionRet + "</adultCommission><childCommission>" + childCommissionRet + "</childCommission><commissionOnTCharge>" + commissionOnTChargeRet + "</commissionOnTCharge></BookingClassFare>";
            xmlRequestData = xmlRequestData + "<Discount>" + DiscountRet + "</Discount><airportTaxChild>" + airportTaxChildRet + "</airportTaxChild><airportTaxInfant>" + airportTaxInfantRet + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakupRet + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakupRet + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakupRet + "</infantTaxBreakup><octax>" + octaxRet + "</octax> </FlightSegment> </FlightSegments>";
            xmlRequestData = xmlRequestData + "<id>" + idRet + "</id><key>" + keyRet + "</key> </OriginDestinationOption></returnFlights>";

            xmlRequestData = xmlRequestData + "<personName>";
            // Dynamic generation of names of adults, infants , Child
            Table tbladults = (Table)this.UpdatePanel1.FindControl("tblAdults");
            for (int i = 1; i <= Convert.ToInt32(Session["adultcnt"]); i++)
            {

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

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

            Table tblChild = (Table)this.UpdatePanel1.FindControl("tblChild");
            for (int i = 1; i <= Convert.ToInt32(Session["childCnt"]); i++)
            {
                TextBox txtFn = (TextBox)tblChild.FindControl("txtCFn" + i);

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

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

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

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

                xmlRequestData = xmlRequestData + "<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.UpdatePanel1.FindControl("tblInfants");
            for (int i = 1; i <= Convert.ToInt32(Session["infantCnt"]); i++)
            {
                TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFn" + i);

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

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

                TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDate" + i);

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

                xmlRequestData = xmlRequestData + "<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>";
            }

            xmlRequestData = xmlRequestData + "</personName><telePhone><phoneNumber>" + txtMobileNo.Text + "</phoneNumber></telePhone><email><emailAddress>" + txtEmailID.Text + "</emailAddress></email><creditcardno>4111111111111111</creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword> <partnerRefId>" + refNo + "</partnerRefId> <Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + ddlAdult.SelectedItem.Value + "</AdultPax><ChildPax>" + ddlChild.SelectedItem.Value + "</ChildPax><InfantPax>" + ddlInfant.SelectedItem.Value + "</InfantPax></Bookingrequest>";
            DataSet dsBookingResponse = new DataSet();

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

            DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "DomesticFlights", airLineName.ToString()); // 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 agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

            string actualFare = lblTotalOnwardReturn.Text;
            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;

            //Return Deduct
            DataSet dsCommSlabRet = objBAL.GetCommissionSlab(Session["Role"].ToString(), "DomesticFlights", airLineNameRet.ToString()); // Change it
            string commisionPercentageRet = string.Empty;
            if (dsCommSlabRet.Tables[0].Rows.Count > 0)
                commisionPercentageRet = dsCommSlabRet.Tables[0].Rows[0]["Commission"].ToString();// Change it
            else
                commisionPercentageRet = "0";

            string actualFareRet = lblTotalOnwardReturn.Text;
            string deductAmountRet = Convert.ToString(Convert.ToDouble(actualFareRet.ToString()) -
                ((Convert.ToDouble(actualFareRet.ToString()) * Convert.ToDouble(commisionPercentageRet)) / 100));
            string commisionFareRet = Convert.ToString(Convert.ToDouble(actualFareRet.ToString()) - Convert.ToDouble(deductAmountRet));

            Session["ActualFare_AgentRet"] = actualFareRet;
            Session["CommisionFare_AgentRet"] = commisionFareRet;
            Session["CommisionPercentage_AgentRet"] = commisionPercentageRet;
            Session["DeductAmount_AgentRet"] = deductAmountRet;

            //End Of ReturnDeduct

            if (Convert.ToDouble(balance) >= (Convert.ToDouble(deductAmount) + Convert.ToDouble(deductAmountRet)))
            {

                dsBookingResponse = objFlights.GetBookingDetails(xmlRequestData.Replace("<br>",""));
            }
            else { return; }

            string error = string.Empty;

            // If there is any Error -- We wont get the transid instead we get error
            if (dsBookingResponse.Tables[0].Columns.Contains("transid"))
            {
                transId = dsBookingResponse.Tables[0].Rows[0]["transid"].ToString();

                string[] commPer = Session["CommisionPercentage_Agent"].ToString().Split('.');
                string[] commPerRet = Session["CommisionPercentage_AgentRet"].ToString().Split('.');
                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(Session["DeductAmount_Agent"].ToString()),
                                        Convert.ToInt32(Session["UserID"].ToString()), refNo, Convert.ToDouble(Session["ActualFare_Agent"].ToString()),
                                        Convert.ToDouble(Session["CommisionFare_Agent"].ToString()), Convert.ToInt32(commPer[0]));
                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(Session["DeductAmount_AgentRet"].ToString()),
                                    Convert.ToInt32(Session["UserID"].ToString()), refNo, Convert.ToDouble(Session["ActualFare_AgentRet"].ToString()),
                                    Convert.ToDouble(Session["CommisionFare_AgentRet"].ToString()), Convert.ToInt32(commPerRet[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;

                #region SaveResponse
                FlightBAL objFlightBal = new FlightBAL();

                objFlightBal.ReferenceNo = refNo;
                objFlightBal.TransId = transId;
                objFlightBal.Status = dsBookingResponse.Tables["Bookingresponse"].Rows[0]["status"].ToString();
                objFlightBal.AdultPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["AdultPax"].ToString());
                objFlightBal.InfantPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["InfantPax"].ToString());
                objFlightBal.ChildPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["ChildPax"].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["ChargeableFares"].Rows[0]["ActualBasefare"].ToString());
                objFlightBal.Tax = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["Tax"].ToString());
                objFlightBal.STax = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["STax"].ToString());
                objFlightBal.Scharge = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["Scharge"].ToString());
                objFlightBal.TDiscount = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["TDiscount"].ToString());
                objFlightBal.TPartnerCommission = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["TPartnerCommission"].ToString());
                objFlightBal.TCharge = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TCharge"].ToString());
                objFlightBal.TMarkUp = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TMarkUp"].ToString());
                objFlightBal.TSDiscount = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TSDiscount"].ToString());
                //added
                objFlightBal.ActualBasefareRet = Convert.ToDecimal(actualBaseFareRet);
                objFlightBal.TaxRet = Convert.ToDecimal(taxRet);
                objFlightBal.STaxRet = Convert.ToDecimal(StaxRet);
                objFlightBal.SchargeRet = Convert.ToDecimal(SChargeRet);
                objFlightBal.TDiscountRet = Convert.ToDecimal(TDiscountRet);
                objFlightBal.TPartnerCommissionRet = Convert.ToDecimal(TPartnerCommissionRet);
                objFlightBal.TChargeRet = Convert.ToDecimal(TChargeRet);
                objFlightBal.TMarkUpRet = Convert.ToDecimal(TMarkupRet);
                objFlightBal.TSDiscountRet = Convert.ToDecimal(TSdiscountRet);
                string givenName = string.Empty;
                string surName = string.Empty;
                string namereference = string.Empty;
                string psgrType = string.Empty;
                string Age = string.Empty;
                string customerInfo = 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 = "adt"; //dsBookingResponse.Tables["CustomerInfo"].Rows[i]["psgrtype"].ToString();

                    string[] str = namereference.ToString().Split(',');
                    if (str[0].ToString() == "C")
                    {
                        psgrType = "Child";
                        Age = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["age"].ToString();
                    }
                    else
                        if (str[0].ToString() == "I")
                        {
                            psgrType = "Infant";
                            Age = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["age"].ToString();
                        }
                        else
                        {
                            psgrType = "Adult";
                        }

                    //   psgrType = "";// dsBookingResponse.Tables["CustomerInfo"].Rows[i]["psgrtype"].ToString();

                    if (psgrType.ToString() != "Adult")
                    {
                        if (psgrType.ToString() == "Child")
                        {

                            if (customerInfo == string.Empty)
                            {
                                customerInfo = str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                            }
                            else
                            {
                                customerInfo = customerInfo + ";" + str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                            }
                        }
                        else
                        {
                            if (customerInfo == string.Empty)
                            {
                                customerInfo = str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age + "M";
                            }
                            else
                            {
                                customerInfo = customerInfo + ";" + str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age + "M";
                            }
                        }
                    }
                    else
                    {
                        if (customerInfo == string.Empty)
                        {
                            customerInfo = str[0].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + "-";
                        }
                        else
                        {
                            customerInfo = customerInfo + ";" + str[0].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + "-";
                        }
                    }
                    //if (customerInfo == string.Empty)
                    //{
                    //    customerInfo = namereference + "|" + givenName + "|" + surName + "|" + psgrType;
                    //}
                    //else
                    //{
                    //    customerInfo = customerInfo + ";" + namereference + "|" + givenName + "|" + surName + "|" + psgrType;
                    //}

                }
                objFlightBal.Customer_Details = customerInfo;
                objFlightBal.telephone = dsBookingResponse.Tables["telePhone"].Rows[0]["PhoneNumber"].ToString();
                objFlightBal.emailAddress = lblEmailAddress.Text = dsBookingResponse.Tables["email"].Rows[0]["emailAddress"].ToString();
                objFlightBal.TripMode = "Round";
                objFlightBal.idRet = idRet;
                objFlightBal.keyRet = keyRet;

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

                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.ArrivalDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ArrivalDateTime"].ToString();
                        objFlightBal.DepartureAirportCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureAirportCode"].ToString();
                        objFlightBal.DepartureDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureDateTime"].ToString();
                        objFlightBal.FlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["FlightNumber"].ToString();
                        objFlightBal.OperatingAirlineCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineCode"].ToString();
                        objFlightBal.OperatingAirlineFlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineFlightNumber"].ToString();
                        objFlightBal.RPH = dsBookingResponse.Tables["FlightSegment"].Rows[j]["RPH"].ToString();
                        objFlightBal.StopQuantity = dsBookingResponse.Tables["FlightSegment"].Rows[j]["StopQuantity"].ToString();
                        objFlightBal.airlineName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airlineName"].ToString();
                        objFlightBal.airportTax = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTax"].ToString();
                        objFlightBal.imageFileName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["imageFileName"].ToString();
                        objFlightBal.Discount = dsBookingResponse.Tables["FlightSegment"].Rows[j]["Discount"].ToString();
                        objFlightBal.airportTaxChild = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTaxChild"].ToString();
                        objFlightBal.airportTaxInfant = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTaxInfant"].ToString();
                        objFlightBal.adultTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["adultTaxBreakUp"].ToString();
                        objFlightBal.ChildTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ChildTaxBreakUp"].ToString();
                        objFlightBal.InfantTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["InfantTaxBreakUp"].ToString();
                        objFlightBal.ocTax = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ocTax"].ToString();
                        objFlightBal.Availability = dsBookingResponse.Tables["BookingClass"].Rows[j]["Availability"].ToString();
                        objFlightBal.ResBookingCode = dsBookingResponse.Tables["BookingClass"].Rows[j]["ResBookDesigCode"].ToString();
                        objFlightBal.adultFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["adultFare"].ToString();
                        objFlightBal.bookingClass = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["bookingClass"].ToString();
                        objFlightBal.ChildFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["ChildFare"].ToString();
                        objFlightBal.ClassType = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["ClassType"].ToString();
                        objFlightBal.farebasisCode = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["farebasisCode"].ToString();
                        objFlightBal.infantFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["infantFare"].ToString();
                        objFlightBal.Fare_Rule = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["Rule"].ToString();
                        objFlightBal.adultCommission = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["adultCommission"].ToString();
                        objFlightBal.childCommission = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["childCommission"].ToString();
                        objFlightBal.CommissionOnTCharge = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["CommissionOnTCharge"].ToString();

                        objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);

                        bool res = objFlightBal.AddDomesticFlightBookingsegments(objFlightBal);
                        if (res)
                        {
                            GetBookingStatus(refNo);
                            GetDetailsForPrint(objFlightBal.ReferenceNo.ToString());

                        }

                #endregion

                        else
                        {
                            error = dsBookingResponse.Tables[0].Rows[0]["error"].ToString();
                            lblStatus.Text = error;
                            lblStatus.ForeColor = System.Drawing.Color.Red;

                        }
                    }
                    lbtnmail.Visible = false;
                    lbtnmail_Click1(sender, e);
                    pnlPassengerDet.Visible = false;
                    lblStatus.Visible = true;
                    lblStatus.Text = "Ticket has been booked successfully. Reference Number is : " + objFlightBal.ReferenceNo.ToString();
                    lblStatus.ForeColor = System.Drawing.Color.Green;
                }
            }
            else
            {
                lblStatus.Text = dsBookingResponse.Tables[0].Rows[0]["Error"].ToString();

                if (lblStatus.Text == "Insufficient Funds")
                {
                    lblStatus.Text = "Please Contact administrator";

                }
                lblStatus.Visible = true;
            }

        }
        catch (Exception ex)
        {

        }
    }
コード例 #3
0
    protected void btnBook_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["UserID"] == null) { Response.Redirect("~/Default.aspx", false); return; }

            dsFilghts = (DataSet)Session["dsDomFlights"];

            #region Variables
            string FlightSegmentsID = string.Empty;
            string originDestination_Id = string.Empty;
            string fareDetailsId = string.Empty;
            string TotalFare = string.Empty;
            /*FlightsSegment*/
            string AirEquipType = string.Empty;
            string ArrivalAirportCode = string.Empty;
            string ArrivalDateTime = string.Empty;
            string DepartureAirportCode = string.Empty;
            string DepartureDateTime = string.Empty;
            string FlightNumber = string.Empty;
            string OperatingAirlineCode = string.Empty;
            string OperatingAirlineFlightNumber = string.Empty;
            string RPH = string.Empty;
            string StopQuantity = string.Empty;
            string airLineName = string.Empty;
            string airportTax = string.Empty;
            string imageFileName = string.Empty;
            string BookingClassAvailability = string.Empty;
            string BookingClassResBookDesigCode = string.Empty;
            string adultFare = string.Empty;
            string bookingclass = string.Empty;
            string childFare = string.Empty;
            string classType = string.Empty;
            string farebasiscode = string.Empty;
            string infantfare = string.Empty;
            string Rule = string.Empty;
            string adultCommission = string.Empty;
            string childCommission = string.Empty;
            string commissionOnTCharge = string.Empty;
            string Discount = string.Empty;
            string airportTaxChild = string.Empty;
            string airportTaxInfant = string.Empty;
            string adultTaxBreakup = string.Empty;
            string childTaxBreakup = string.Empty;
            string infantTaxBreakup = string.Empty;
            string octax = string.Empty;
            string id = string.Empty;
            string key = string.Empty;
            string TCharge = string.Empty;
            string TMarkup = string.Empty;
            string TSdiscount = string.Empty;
            string TPartnerCommission = string.Empty;
            string actualBaseFare = string.Empty;
            string tax = string.Empty;
            string Stax = string.Empty;
            string SCharge = string.Empty;
            string TDiscount = string.Empty;

            #endregion

            DataTable dtFlightsSegment = dsFilghts.Tables[9];
            if (dtFlightsSegment.Rows.Count > 0)
            {
                DataRow[] rowFilghtSegment = dtFlightsSegment.Select("FlightSegment_ID=" + Convert.ToInt32(lblFlightSegmentId1.Text));
                FlightSegmentsID = rowFilghtSegment[0]["FlightSegments_Id"].ToString();
                AirEquipType = rowFilghtSegment[0]["AirEquipType"].ToString();
                ArrivalAirportCode = rowFilghtSegment[0]["ArrivalAirportCode"].ToString();
                ArrivalDateTime = rowFilghtSegment[0]["ArrivalDateTime"].ToString();
                DepartureAirportCode = rowFilghtSegment[0]["DepartureAirportCode"].ToString();
                DepartureDateTime = rowFilghtSegment[0]["DepartureDateTime"].ToString();
                FlightNumber = rowFilghtSegment[0]["FlightNumber"].ToString();
                OperatingAirlineCode = rowFilghtSegment[0]["OperatingAirlineCode"].ToString();
                OperatingAirlineFlightNumber = rowFilghtSegment[0]["OperatingAirlineFlightNumber"].ToString();
                RPH = rowFilghtSegment[0]["RPH"].ToString();
                StopQuantity = rowFilghtSegment[0]["StopQuantity"].ToString();
                airLineName = rowFilghtSegment[0]["airLineName"].ToString();
                airportTax = rowFilghtSegment[0]["airportTax"].ToString();
                imageFileName = rowFilghtSegment[0]["imageFileName"].ToString();
                Discount = rowFilghtSegment[0]["Discount"].ToString();
                airportTaxChild = rowFilghtSegment[0]["airportTaxChild"].ToString();
                airportTaxInfant = rowFilghtSegment[0]["airportTaxInfant"].ToString();
                adultTaxBreakup = rowFilghtSegment[0]["adultTaxBreakup"].ToString();
                childTaxBreakup = rowFilghtSegment[0]["childTaxBreakup"].ToString();
                infantTaxBreakup = rowFilghtSegment[0]["infantTaxBreakup"].ToString();
                octax = rowFilghtSegment[0]["octax"].ToString();
            }

            DataTable dtFlightSegments = dsFilghts.Tables[8];
            if (dtFlightSegments.Rows.Count > 0)
            {
                DataRow[] rowFilghtSegments = dtFlightSegments.Select("FlightSegments_Id=" + FlightSegmentsID);
                originDestination_Id = rowFilghtSegments[0]["OriginDestinationOption_Id"].ToString();
            }
            DataTable dtFareDetails = dsFilghts.Tables[5];
            if (dtFareDetails.Rows.Count > 0)
            {
                DataRow[] rowFareDetails = dtFareDetails.Select("OriginDestinationOption_Id=" + originDestination_Id);
                fareDetailsId = rowFareDetails[0]["FareDetails_Id"].ToString();
            }
            DataTable dtNonChargeableFares = dsFilghts.Tables[7];
            if (dtNonChargeableFares.Rows.Count > 0)
            {
                DataRow[] rowNonChargeableFareDetails = dtNonChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                TCharge = rowNonChargeableFareDetails[0]["TCharge"].ToString();
                TMarkup = rowNonChargeableFareDetails[0]["TMarkup"].ToString();
                TSdiscount = rowNonChargeableFareDetails[0]["TSdiscount"].ToString();
            }
            DataTable dtChargeableFares = dsFilghts.Tables[6];
            if (dtChargeableFares.Rows.Count > 0)
            {
                DataRow[] rowChargeableFareDetails = dtChargeableFares.Select("FareDetails_Id=" + fareDetailsId);
                TPartnerCommission = rowChargeableFareDetails[0]["TPartnerCommission"].ToString();
                actualBaseFare = rowChargeableFareDetails[0]["ActualBaseFare"].ToString();
                tax = rowChargeableFareDetails[0]["Tax"].ToString();
                Stax = rowChargeableFareDetails[0]["Stax"].ToString();
                SCharge = rowChargeableFareDetails[0]["SCharge"].ToString();
                TDiscount = rowChargeableFareDetails[0]["TDiscount"].ToString();
                TotalFare = (Convert.ToDecimal(actualBaseFare) + Convert.ToDecimal(tax) + Convert.ToDecimal(Stax) + Convert.ToDecimal(TCharge) + Convert.ToDecimal(TMarkup)).ToString();//+ Convert.ToDecimal(SCharge) + Convert.ToDecimal(TDiscount)

            }

            DataTable dtBookingClass = dsFilghts.Tables[10];
            if (dtBookingClass.Rows.Count > 0)
            {
                DataRow[] rowBookingClass = dtBookingClass.Select("FlightSegment_ID=" + Convert.ToInt32(lblFlightSegmentId1.Text));
                BookingClassAvailability = rowBookingClass[0]["Availability"].ToString();
                BookingClassResBookDesigCode = rowBookingClass[0]["ResBookDesigCode"].ToString();
            }

            DataTable dtBookingFareRules = dsFilghts.Tables[11];
            if (dtBookingFareRules.Rows.Count > 0)
            {
                DataRow[] rowBookingFareRules = dtBookingFareRules.Select("FlightSegment_ID=" + Convert.ToInt32(lblFlightSegmentId1.Text));
                adultFare = rowBookingFareRules[0]["adultFare"].ToString();
                bookingclass = rowBookingFareRules[0]["bookingclass"].ToString();
                farebasiscode = rowBookingFareRules[0]["farebasiscode"].ToString();
                Rule = rowBookingFareRules[0]["Rule"].ToString().Replace("<br>", "");
                adultCommission = rowBookingFareRules[0]["adultCommission"].ToString();
                childCommission = rowBookingFareRules[0]["childCommission"].ToString();
                infantfare = (infantCnt > 0) ? rowBookingFareRules[0]["infantfare"].ToString() : "1";
                classType = rowBookingFareRules[0]["classType"].ToString();
                childFare = (childCnt > 0) ? rowBookingFareRules[0]["childFare"].ToString() : "1";
                commissionOnTCharge = rowBookingFareRules[0]["commissionOnTCharge"].ToString();

            }

            DataTable dtOriginDestinationOption = dsFilghts.Tables[4];
            if (dtOriginDestinationOption.Rows.Count > 0)
            {
                DataRow[] rowOriginDestinationOption = dtOriginDestinationOption.Select("OriginDestinationOption_Id=" + originDestination_Id);
                id = rowOriginDestinationOption[0]["id"].ToString();
                key = rowOriginDestinationOption[0]["key"].ToString();
            }
            if (Session["Role"].ToString() == "User")
            {

                #region SaveRequestToDBBeforePG

                string refNo = Common.GetFlightsReferenceNo("LJDF");
                Session["Order_Id"] = refNo.ToString();
                FlightBAL objFlightBal = new FlightBAL();

                objFlightBal.ReferenceNo = refNo;
                objFlightBal.TransId = string.Empty;
                objFlightBal.Status = "Pending";
                objFlightBal.AdultPax =  Convert.ToInt32(Session["adultcnt"]);
                objFlightBal.InfantPax = Convert.ToInt32(Session["infantCnt"]);
                objFlightBal.ChildPax = Convert.ToInt32(Session["childCnt"]);
                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.Scharge = Convert.ToDecimal(SCharge);
                objFlightBal.TDiscount = Convert.ToDecimal(TDiscount);
                objFlightBal.TPartnerCommission = Convert.ToDecimal(TPartnerCommission);
                objFlightBal.TCharge = Convert.ToDecimal(TCharge);
                objFlightBal.TMarkUp = Convert.ToDecimal(TMarkup);
                objFlightBal.TSDiscount = Convert.ToDecimal(TSdiscount);
                string givenName = string.Empty;
                string surName = string.Empty;
                string namereference = string.Empty;
                string psgrType = string.Empty;
                string Age = string.Empty;
                string customerInfo = string.Empty;
                Table tbladults1 = (Table)this.UpdatePanel1.FindControl("tblAdults");
                for (int l = 1; l <= Convert.ToInt32(Session["adultcnt"]); l++)
                {

                    TextBox txtFn = (TextBox)tbladults1.FindControl("txtFn" + l);
                    TextBox txtLn = (TextBox)tbladults1.FindControl("txtLn" + l);
                    DropDownList ddlTitle = (DropDownList)tbladults1.FindControl("ddlTitle" + 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 tblChild1 = (Table)this.UpdatePanel1.FindControl("tblChild");
                for (int j = 1; j <= Convert.ToInt32(Session["childCnt"]); j++)
                {
                    TextBox txtFn = (TextBox)tblChild1.FindControl("txtCFn" + j);

                    TextBox txtLn = (TextBox)tblChild1.FindControl("txtCLn" + j);

                    DropDownList ddlTitle = (DropDownList)tblChild1.FindControl("ddlCTitle" + j);

                    TextBox txtBirthDate = (TextBox)tblChild1.FindControl("txtCBirthDate" + 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.ToString();
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "Chd" + "|" + age + "|" + txtBirthDate.Text.ToString();
                    }
                    //  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 tblInfants1 = (Table)this.UpdatePanel1.FindControl("tblInfants");
                for (int k = 1; k <= Convert.ToInt32(Session["infantCnt"]); k++)
                {
                    TextBox txtFn = (TextBox)tblInfants1.FindControl("txtIFn" + k);

                    TextBox txtLn = (TextBox)tblInfants1.FindControl("txtILn" + k);

                    DropDownList ddlTitle = (DropDownList)tblInfants1.FindControl("ddlITitle" + k);

                    TextBox txtBirthDate = (TextBox)tblInfants1.FindControl("txtIBirthDate" + 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.ToString();
                    }
                    else
                    {
                        customerInfo = customerInfo + ";" + ddlTitle.SelectedItem.Text + "|" + txtFn.Text + "|" + txtLn.Text + "|" + "Inf" + "|" + age + "|" + txtBirthDate.Text.ToString();
                    }
                    //  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>";
                }

                objFlightBal.Address = txtCity.Text + "," + txtState.Text + "," + ddlcountry.SelectedValue + "," + txtPostalCode.Text + ",";
                objFlightBal.Customer_Details = customerInfo;
                //objFlightBal.Customer_Details = "Mr.|rajini|reguri|Adt|";
                objFlightBal.telephone = txtPhoneNum.Text;
                objFlightBal.emailAddress = lblEmailAddress.Text = txtEmailID.Text;
                objFlightBal.TripMode = "One";

                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                objFlightBal.Type = "User";
                objFlightBal.id = id;
                objFlightBal.key = key;

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

                objFlightBal.FlightBookingID = flightBookingId.ToString();
                objFlightBal.AirEquipType = AirEquipType;
                objFlightBal.ArrivalAirportCode = ArrivalAirportCode;
                objFlightBal.ArrivalDateTime = ArrivalDateTime;
                objFlightBal.DepartureAirportCode = DepartureAirportCode;
                objFlightBal.DepartureDateTime = DepartureDateTime;
                objFlightBal.FlightNumber = FlightNumber;
                objFlightBal.OperatingAirlineCode = OperatingAirlineCode;
                objFlightBal.OperatingAirlineFlightNumber = OperatingAirlineFlightNumber;
                objFlightBal.RPH = RPH;
                objFlightBal.StopQuantity = StopQuantity;
                objFlightBal.airlineName = airLineName;
                objFlightBal.airportTax = airportTax;
                objFlightBal.imageFileName = imageFileName;
                objFlightBal.Discount = Discount;
                objFlightBal.airportTaxChild = airportTaxChild;
                objFlightBal.airportTaxInfant = airportTaxInfant;
                objFlightBal.adultTaxBreakUp = adultTaxBreakup;
                objFlightBal.ChildTaxBreakUp = childTaxBreakup;
                objFlightBal.InfantTaxBreakUp = infantTaxBreakup;
                objFlightBal.ocTax = octax;
                objFlightBal.Availability = BookingClassAvailability;
                objFlightBal.ResBookingCode = BookingClassResBookDesigCode;
                objFlightBal.adultFare = adultFare;
                objFlightBal.bookingClass = bookingclass;
                objFlightBal.ChildFare = childFare;
                objFlightBal.ClassType = classType;
                objFlightBal.farebasisCode = farebasiscode;
                objFlightBal.infantFare = infantfare;
                objFlightBal.Fare_Rule = Rule;
                objFlightBal.adultCommission = adultCommission;
                objFlightBal.childCommission = childCommission;
                objFlightBal.CommissionOnTCharge = commissionOnTCharge;
                objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);

                bool res = objFlightBal.AddDomesticFlightBookingsegments(objFlightBal);

                if (res)
                {
                    try
                    {
                        if (Page.IsValid)
                        {
                            Response.Redirect("~/pay.aspx?val=Dom", false);
                        }
                        else
                        {
                            lblMsg.Text = "Enter Valid Data";
                            lblMsg.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                    catch (Exception ex)
                    {
                        //  LogError("frmSearchBus.aspx", "paymentgateway", DateTime.Now, ex.Message.ToString());
                        // lblMsg1.Visible = true;
                        // lblMsg1.Text = "Error in the payment gateway";
                    }
                }

                #endregion

            }
            else
            {

            #region Pricing

            String XMLPricing = "<pricingrequest><onwardFlights><OriginDestinationOption><FareDetails><ChargeableFares><ActualBaseFare>" + actualBaseFare + "</ActualBaseFare><Tax>" + tax + "</Tax> <STax>" + Stax + "</STax><SCharge>" + SCharge + "</SCharge> <TDiscount>" + TDiscount + "</TDiscount><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TCharge + "</TCharge> <TMarkup>" + TMarkup + "</TMarkup><TSdiscount>" + TDiscount + "</TSdiscount> </NonchargeableFares></FareDetails> <FlightSegments> <FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><RPH>" + RPH + "</RPH> <StopQuantity>" + StopQuantity + "</StopQuantity><airLineName>" + airLineName + "</airLineName><airportTax>" + airportTax + "</airportTax><imageFileName>" + imageFileName + "</imageFileName> <BookingClass><Availability>" + BookingClassAvailability + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCode + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFare + "</adultFare><bookingclass>" + bookingclass + "</bookingclass> <childFare>" + childFare + "</childFare><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><infantfare>" + infantfare + "</infantfare> <Rule>" + Rule.Replace("<br>","") + "</Rule><adultCommission>" + adultCommission + "</adultCommission><childCommission>" + childCommission + "</childCommission><commissionOnTCharge>" + commissionOnTCharge + "</commissionOnTCharge></BookingClassFare> <Discount>" + Discount + "</Discount><airportTaxChild>" + airportTaxChild + "</airportTaxChild><airportTaxInfant>" + airportTaxInfant + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakup + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakup + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakup + "</infantTaxBreakup><octax>" + octax + "</octax> </FlightSegment> </FlightSegments><id>" + id + "</id><key>" + key + "</key> </OriginDestinationOption></onwardFlights><returnFlights/> <telePhone>" + txtPhoneNum.Text + "</telePhone><email>" + txtEmailID.Text + "</email> <creditcardno></creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + Session["adultcnt"].ToString() + "</AdultPax><ChildPax>" + Session["childCnt"].ToString() + "</ChildPax><InfantPax>" + Session["infantCnt"].ToString() + "</InfantPax></pricingrequest>";
            DataSet dsFlightPricing = objFlights.GetPricingDetails(XMLPricing.Replace("<br>",""));

            if (!dsFlightPricing.Tables[0].Columns.Contains("error"))
            {

                DataTable dtFlightSegment = dsFlightPricing.Tables["FlightSegment"];
                string PricingFlightSegmentsId = dsFlightPricing.Tables["FlightSegment"].Rows[0]["FlightSegments_Id"].ToString();
                DataTable dtchangeFlightSegments = dsFlightPricing.Tables[6];
                if (dtchangeFlightSegments.Rows.Count > 0)
                {
                    DataRow[] rowchangeFilghtSegments = dtchangeFlightSegments.Select("FlightSegments_Id=" + PricingFlightSegmentsId);
                    originDestination_Id = rowchangeFilghtSegments[0]["OriginDestinationOption_Id"].ToString();
                }

                DataTable dtchangeFareDetails = dsFlightPricing.Tables[3];
                if (dtchangeFareDetails.Rows.Count > 0)
                {
                    DataRow[] rowchangeFareDetails = dtchangeFareDetails.Select("OriginDestinationOption_Id=" + originDestination_Id);
                    fareDetailsId = rowchangeFareDetails[0]["FareDetails_Id"].ToString();
                }

                DataTable dtchangeprice = dsFlightPricing.Tables[4];
                DataTable dtchangepriceNon = dsFlightPricing.Tables[5];
                if (dtchangeprice.Rows.Count > 0)
                {
                    DataRow[] rowchangeprices = dtchangeprice.Select("FareDetails_Id=" + fareDetailsId);
                    DataRow[] rowchangepricesNon = dtchangepriceNon.Select("FareDetails_Id=" + fareDetailsId);
                    TPartnerCommission = rowchangeprices[0]["TPartnerCommission"].ToString();
                    actualBaseFare = rowchangeprices[0]["ActualBaseFare"].ToString();
                    tax = rowchangeprices[0]["Tax"].ToString();
                    Stax = rowchangeprices[0]["Stax"].ToString();
                    SCharge = rowchangeprices[0]["SCharge"].ToString();
                    TDiscount = rowchangeprices[0]["TDiscount"].ToString();
                    TotalFare = (Convert.ToDecimal(actualBaseFare) + Convert.ToDecimal(tax) + Convert.ToDecimal(Stax) + Convert.ToDecimal(rowchangepricesNon[0]["TCharge"].ToString()).ToString() + Convert.ToDecimal(rowchangepricesNon[0]["TMarkup"].ToString()).ToString()); //+ Convert.ToDecimal(TDiscount)).ToString()+.ToDecimal(SCharge)  ;
                }
            }

            #endregion

            string refNo = Common.GetFlightsReferenceNo("LJDF");

            String xmlRequestData = "<Bookingrequest><onwardFlights><OriginDestinationOption><FareDetails> <ChargeableFares><ActualBaseFare>" + actualBaseFare + "</ActualBaseFare> <Tax>" + tax + "</Tax><STax>" + Stax + "</STax> <SCharge>" + SCharge + "</SCharge><TDiscount>" + TDiscount + "</TDiscount><TPartnerCommission>" + TPartnerCommission + "</TPartnerCommission></ChargeableFares> <NonchargeableFares><TCharge>" + TCharge + "</TCharge> <TMarkup>" + TMarkup + "</TMarkup><TSdiscount>" + TSdiscount + "</TSdiscount> </NonchargeableFares></FareDetails>";
            xmlRequestData = xmlRequestData + "<FlightSegments> <FlightSegment><AirEquipType>" + AirEquipType + "</AirEquipType><ArrivalAirportCode>" + ArrivalAirportCode + "</ArrivalAirportCode><ArrivalDateTime>" + ArrivalDateTime + "</ArrivalDateTime><DepartureAirportCode>" + DepartureAirportCode + "</DepartureAirportCode><DepartureDateTime>" + DepartureDateTime + "</DepartureDateTime><FlightNumber>" + FlightNumber + "</FlightNumber><OperatingAirlineCode>" + OperatingAirlineCode + "</OperatingAirlineCode><OperatingAirlineFlightNumber>" + OperatingAirlineFlightNumber + "</OperatingAirlineFlightNumber><RPH>" + RPH + "</RPH> <StopQuantity>" + StopQuantity + "</StopQuantity><airLineName>" + airLineName + "</airLineName><airportTax>" + airportTax + "</airportTax><imageFileName>" + imageFileName + "</imageFileName>";
            xmlRequestData = xmlRequestData + "<BookingClass><Availability>" + BookingClassAvailability + "</Availability><ResBookDesigCode>" + BookingClassResBookDesigCode + "</ResBookDesigCode> </BookingClass><BookingClassFare> <adultFare>" + adultFare + "</adultFare><bookingclass>" + bookingclass + "</bookingclass> <childFare>" + childFare + "</childFare><classType>" + classType + "</classType><farebasiscode>" + farebasiscode + "</farebasiscode><infantfare>" + infantfare + "</infantfare> <Rule>" + Rule + "</Rule><adultCommission>" + adultCommission + "</adultCommission><childCommission>" + childCommission + "</childCommission><commissionOnTCharge>" + commissionOnTCharge + "</commissionOnTCharge></BookingClassFare>";
            xmlRequestData = xmlRequestData + "<Discount>" + Discount + "</Discount><airportTaxChild>" + airportTaxChild + "</airportTaxChild><airportTaxInfant>" + airportTaxInfant + "</airportTaxInfant><adultTaxBreakup>" + adultTaxBreakup + "</adultTaxBreakup><childTaxBreakup>" + childTaxBreakup + "</childTaxBreakup><infantTaxBreakup>" + infantTaxBreakup + "</infantTaxBreakup><octax>" + octax + "</octax> </FlightSegment> </FlightSegments>";
            xmlRequestData = xmlRequestData + "<id>" + id + "</id><key>" + key + "</key> </OriginDestinationOption></onwardFlights><returnFlights/><personName>";

            // Dynamic generation of names of adults, infants , Child

            Table tbladults = (Table)this.UpdatePanel1.FindControl("tblAdults");
            for (int i = 1; i <=  Convert.ToInt32(Session["adultcnt"]); i++)
            {

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

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

            Table tblChild = (Table)this.UpdatePanel1.FindControl("tblChild");
            for (int i = 1; i <= Convert.ToInt32(Session["childCnt"]) ; i++)
            {
                TextBox txtFn = (TextBox)tblChild.FindControl("txtCFn" + i);

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

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

                TextBox txtBirthDate = (TextBox)tblChild.FindControl("txtCBirthDate" + i);
                DateTime strdate = Convert.ToDateTime(txtBirthDate.Text);

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

                xmlRequestData = xmlRequestData + "<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.UpdatePanel1.FindControl("tblInfants");
            for (int i = 1; i <= Convert.ToInt32(Session["infantCnt"]) ; i++)
            {
                TextBox txtFn = (TextBox)tblInfants.FindControl("txtIFn" + i);

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

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

                TextBox txtBirthDate = (TextBox)tblInfants.FindControl("txtIBirthDate" + i);

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

                xmlRequestData = xmlRequestData + "<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>";
            }

            xmlRequestData = xmlRequestData + "</personName><telePhone><phoneNumber>" + txtMobileNo.Text + "</phoneNumber></telePhone><email><emailAddress>" + txtEmailID.Text + "</emailAddress></email><creditcardno>4111111111111111</creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword> <partnerRefId>" + refNo + "</partnerRefId> <Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + ddlAdult.SelectedItem.Value + "</AdultPax><ChildPax>" + ddlChild.SelectedItem.Value + "</ChildPax><InfantPax>" + ddlInfant.SelectedItem.Value + "</InfantPax></Bookingrequest>";

                DataSet dsBookingResponse = new DataSet();
                #region CSE
                if (Session["Role"].ToString() == "CSE")
                    {
                        if (chkonbehalfof.Checked == true)
                        {
                            ListItem value = ddlagent1.Items.FindByText(txtagentname.Text.ToString());
                            if (value != null)
                            {
                                ddlagent1.SelectedItem.Value = value.Value;
                                Session["AgentId_Agent"] = ddlagent1.SelectedItem.Value;

                                DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(ddlagent1.SelectedValue));
                                DataSet dsCommSlab = objBAL.GetCommissionSlab("Agent", "DomesticFlights", airLineName.ToString()); // 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 agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

                                string actualFare = TotalFare;
                                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 = objFlights.GetBookingDetails(xmlRequestData.Replace("<br>", ""));
                                }
                                else

                                {
                                      mp3.Show();
                                lblerror.Text = "Please contact administrator";
                                    return;
                                }
                            }
                            else
                            {
                                mp3.Show();
                                lblerror.Text = "Agent Username Does not exists";
                                return;
                            }
                        }
                        else
                        {
                             dsBookingResponse = objFlights.GetBookingDetails(xmlRequestData.Replace("<br>", ""));
                        }
                    }
                #endregion
                #region Agent
                else if (Session["Role"].ToString() == "Agent")
                {
                    DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                    DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "DomesticFlights", airLineName.ToString()); // 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 agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

                    string actualFare = TotalFare;
                    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 = objFlights.GetBookingDetails(xmlRequestData.Replace("<br>", ""));
                    }
                    else
                    {
                        mp3.Show();

                        lblerror.Text = "Please Contact administrator";

                        return;
                    }
                }
                #endregion
                else
                {
                    dsBookingResponse = objFlights.GetBookingDetails(xmlRequestData.Replace("<br>", ""));
                }

                string error = string.Empty;

                // If there is any Error -- We wont get the transid instead we get error
                if (dsBookingResponse.Tables[0].Columns.Contains("transid"))
                {
                    transId = dsBookingResponse.Tables[0].Rows[0]["transid"].ToString();

                    #region SaveResponse
                    FlightBAL objFlightBal = new FlightBAL();

                    objFlightBal.ReferenceNo = refNo;
                    objFlightBal.TransId = transId;
                    objFlightBal.Status = dsBookingResponse.Tables["Bookingresponse"].Rows[0]["status"].ToString();
                    objFlightBal.AdultPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["AdultPax"].ToString());
                    objFlightBal.InfantPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["InfantPax"].ToString());
                    objFlightBal.ChildPax = Convert.ToInt32(dsBookingResponse.Tables["Bookingresponse"].Rows[0]["ChildPax"].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["ChargeableFares"].Rows[0]["ActualBasefare"].ToString());
                    objFlightBal.Tax = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["Tax"].ToString());
                    objFlightBal.STax = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["STax"].ToString());
                    objFlightBal.Scharge = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["Scharge"].ToString());
                    objFlightBal.TDiscount = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["TDiscount"].ToString());
                    objFlightBal.TPartnerCommission = Convert.ToDecimal(dsBookingResponse.Tables["ChargeableFares"].Rows[0]["TPartnerCommission"].ToString());
                    objFlightBal.TCharge = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TCharge"].ToString());
                    objFlightBal.TMarkUp = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TMarkUp"].ToString());
                    objFlightBal.TSDiscount = Convert.ToDecimal(dsBookingResponse.Tables["NonChargeableFares"].Rows[0]["TSDiscount"].ToString());
                    string givenName = string.Empty;
                    string surName = string.Empty;
                    string namereference = string.Empty;
                    string psgrType = string.Empty;
                    string Age = string.Empty;
                    string customerInfo = 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();

                        string[] str = namereference.ToString().Split(',');
                        if (str[0].ToString() == "C")
                        {
                            psgrType = "Child";
                            Age = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["age"].ToString();
                        }
                        else
                            if (str[0].ToString() == "I")
                            {
                                psgrType = "Infant";
                                Age = dsBookingResponse.Tables["CustomerInfo"].Rows[i]["age"].ToString();
                            }
                            else
                            {
                                psgrType = "Adult";
                            }

                        //   psgrType = "";// dsBookingResponse.Tables["CustomerInfo"].Rows[i]["psgrtype"].ToString();

                        if (psgrType.ToString() != "Adult")
                        {
                            if (psgrType.ToString() == "Child")
                            {
                                if (customerInfo == string.Empty)
                                {
                                    customerInfo = str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                                else
                                {
                                    customerInfo = customerInfo + ";" + str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age;
                                }
                            }
                            else
                            {
                                if (customerInfo == string.Empty)
                                {
                                    customerInfo = str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age + "M";
                                }
                                else
                                {
                                    customerInfo = customerInfo + ";" + str[1].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + Age + "M";
                                }
                            }
                        }
                        else
                        {
                            if (customerInfo == string.Empty)
                            {
                                customerInfo = str[0].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + "-";
                            }
                            else
                            {
                                customerInfo = customerInfo + ";" + str[0].ToString() + "|" + givenName + "|" + surName + "|" + psgrType + "|" + "-";
                            }
                        }

                    }
                    objFlightBal.Customer_Details = customerInfo;
                    objFlightBal.telephone = dsBookingResponse.Tables["telePhone"].Rows[0]["PhoneNumber"].ToString();
                    objFlightBal.emailAddress = lblEmailAddress.Text = dsBookingResponse.Tables["email"].Rows[0]["emailAddress"].ToString();
                    objFlightBal.TripMode = "One";

                    objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);

                    if (Session["Role"].ToString() == "CSE")
                    {
                        if (chkonbehalfof.Checked == true)
                        {

                            objFlightBal.CreatedBy = Convert.ToInt32(Session["AgentId_Agent"]);
                                string[] commPer = Session["CommisionPercentage_Agent"].ToString().Split('.');
                                string[] commPerRet = Session["CommisionPercentage_AgentRet"].ToString().Split('.');
                                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(Session["DeductAmount_Agent"].ToString()),
                                                        Convert.ToInt32(Session["AgentId_Agent"].ToString()), refNo, Convert.ToDouble(Session["ActualFare_Agent"].ToString()),
                                                        Convert.ToDouble(Session["CommisionFare_Agent"].ToString()), Convert.ToDouble(commPer[0]));

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

                                string balanceAgent = dsBalanceA.Tables[0].Rows[0]["Balance"].ToString();

                                Session["Balance"] = balanceAgent;
                            }
                            else
                            {

                            }

                    }

                    else   if (Session["Role"].ToString() == "Agent")
                    {
                        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()), refNo, Convert.ToDouble(Session["ActualFare_Agent"].ToString()),
                                                Convert.ToDouble(Session["CommisionFare_Agent"].ToString()), Convert.ToDouble(Session["CommisionPercentage_Agent"]));

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

                    // bool res = objFlightBal.AddDomesticFlightBooking(objFlightBal);

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

                    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.ArrivalDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ArrivalDateTime"].ToString();
                            objFlightBal.DepartureAirportCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureAirportCode"].ToString();
                            objFlightBal.DepartureDateTime = dsBookingResponse.Tables["FlightSegment"].Rows[j]["DepartureDateTime"].ToString();
                            objFlightBal.FlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["FlightNumber"].ToString();
                            objFlightBal.OperatingAirlineCode = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineCode"].ToString();
                            objFlightBal.OperatingAirlineFlightNumber = dsBookingResponse.Tables["FlightSegment"].Rows[j]["OperatingAirlineFlightNumber"].ToString();
                            objFlightBal.RPH = dsBookingResponse.Tables["FlightSegment"].Rows[j]["RPH"].ToString();
                            objFlightBal.StopQuantity = dsBookingResponse.Tables["FlightSegment"].Rows[j]["StopQuantity"].ToString();
                            objFlightBal.airlineName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airlineName"].ToString();
                            objFlightBal.airportTax = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTax"].ToString();
                            objFlightBal.imageFileName = dsBookingResponse.Tables["FlightSegment"].Rows[j]["imageFileName"].ToString();
                            objFlightBal.Discount = dsBookingResponse.Tables["FlightSegment"].Rows[j]["Discount"].ToString();
                            objFlightBal.airportTaxChild = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTaxChild"].ToString();
                            objFlightBal.airportTaxInfant = dsBookingResponse.Tables["FlightSegment"].Rows[j]["airportTaxInfant"].ToString();
                            objFlightBal.adultTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["adultTaxBreakUp"].ToString();
                            objFlightBal.ChildTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ChildTaxBreakUp"].ToString();
                            objFlightBal.InfantTaxBreakUp = dsBookingResponse.Tables["FlightSegment"].Rows[j]["InfantTaxBreakUp"].ToString();
                            objFlightBal.ocTax = dsBookingResponse.Tables["FlightSegment"].Rows[j]["ocTax"].ToString();
                            objFlightBal.Availability = dsBookingResponse.Tables["BookingClass"].Rows[j]["Availability"].ToString();
                            objFlightBal.ResBookingCode = dsBookingResponse.Tables["BookingClass"].Rows[j]["ResBookDesigCode"].ToString();
                            objFlightBal.adultFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["adultFare"].ToString();
                            objFlightBal.bookingClass = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["bookingClass"].ToString();
                            objFlightBal.ChildFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["ChildFare"].ToString();
                            objFlightBal.ClassType = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["ClassType"].ToString();
                            objFlightBal.farebasisCode = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["farebasisCode"].ToString();
                            objFlightBal.infantFare = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["infantFare"].ToString();
                            objFlightBal.Fare_Rule = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["Rule"].ToString();
                            objFlightBal.adultCommission = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["adultCommission"].ToString();
                            objFlightBal.childCommission = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["childCommission"].ToString();
                            objFlightBal.CommissionOnTCharge = dsBookingResponse.Tables["BookingClassFare"].Rows[j]["CommissionOnTCharge"].ToString();

                            objFlightBal.CreatedBy = Convert.ToInt32(Session["UserID"]);
                            if (Session["Role"].ToString() == "CSE")
                            {
                                if (chkonbehalfof.Checked == true)
                                {
                                    objFlightBal.CreatedBy = Convert.ToInt32(Session["AgentId_Agent"]);
                                }
                            }

                            bool res = objFlightBal.AddDomesticFlightBookingsegments(objFlightBal);

                            if (res)
                            {
                                GetBookingStatus(refNo);
                                GetDetailsForPrint(objFlightBal.ReferenceNo.ToString());

                            }

                    #endregion

                            else
                            {
                                error = dsBookingResponse.Tables[0].Rows[0]["error"].ToString();
                                lblStatus.Text = error;

                            }
                        }
                        lbtnmail.Visible = false;
                        pnlSearch.Visible = false;
                        pnlPassengerDet.Visible = false;
                        lblStatus.Visible = true;
                        lblStatus.Text = "Ticket has been booked successfully. Reference Number is : " + objFlightBal.ReferenceNo.ToString();
                        lblStatus.ForeColor = System.Drawing.Color.Green;
                        lbtnmail_Click1(sender, e);
                    }
                }
                else
                {
                    mp3.Show();
                    lblerror.Text = dsBookingResponse.Tables[0].Rows[0]["error"].ToString();
                    if (lblerror.Text == "Insufficient Funds")
                    {
                        lblerror.Text = "Please Contact administrator";

                    }
                }

            }
        }
        catch (Exception ex)
        {

        }
    }