protected void btnAgentLogin_Click(object sender, EventArgs e)
    {
        try
        {
            ClsBAL objManabusBAL = new ClsBAL();
            objManabusBAL.userName = Convert.ToString(txtAgentName.Text);
            objManabusBAL.password = Convert.ToString(txtAgentPassword.Text);

            if (objManabusBAL.CheckUser() == "Valid User")
            {
                if (Session["Role"] != null)
                {

                     if (Session["Role"].ToString() == "Agent")
                    {
                        System.Data.DataSet ds = objManabusBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                        Session["Balance"] = ds.Tables[0].Rows[0]["Balance"].ToString();
                        Session["View"] = "AgentView";
                        string ss = ds.Tables[0].Rows[0]["Status"].ToString();
                        if (ss.ToUpper().ToString() != "HOLD")
                        {
                            Response.Redirect("~/Default.aspx", false);
                        }
                        else
                        {
                            lblEmpMsg.Text = "Your account is on HOLD. Please contact the administrator.";
                            lblEmpMsg.ForeColor = System.Drawing.Color.Red;
                            Session["UserID"] = null;
                        }
                    }

                    else
                    {
                        lblEmpMsg.Text = "UserName / Password Is Incorrect.";
                        lblEmpMsg.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            else
            {
                lblEmpMsg.Text = "UserName / Password Is Incorrect.";
                lblEmpMsg.ForeColor = System.Drawing.Color.Red;
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
            throw ex;
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        objResult.ReferanceId = txtBookingRefNo.Text;
        objResult.EmailId = txtEmailId.Text;
        objResult.ScreenInd = blossom.GetCancellationdetails;

        _objDataSet = (DataSet)objResult.fnGetData();
        if (_objDataSet != null)
        {
            if (_objDataSet.Tables[0].Rows[0]["Status"].ToString() == "Canceled")
            {
                lblCancel.Text = "Ticket Has been already cancelled";
                lblCancel.ForeColor = System.Drawing.Color.Red;
                return;
            }
            string actualfare = _objDataSet.Tables[0].Rows[0]["BasicFare"].ToString();
            comm = 10.0;
            double cancellationAmount = Convert.ToDouble(actualfare) * comm / 100;
            double refundTotalAmount = Convert.ToDouble(actualfare) - cancellationAmount;
            ClsBAL objBAL;
            objBAL = new ClsBAL();
            objBAL.AdjustAgentBalance1(txtBookingRefNo.Text.Trim().ToString(),
                Convert.ToDouble(refundTotalAmount), Convert.ToDouble(cancellationAmount),
                Convert.ToInt32(Session["UserID"].ToString()));

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

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

            string str=objBAL.Updatecancelstatus(txtBookingRefNo.Text,"Canceled");
            lblCancel.Text = str;
            lblCancel.ForeColor = System.Drawing.Color.Green;

            txtEmailId.Text = txtBookingRefNo.Text = "";

        }
        else
        {
            lblCancel.Text = "Invalid Ref/EmailId";
        }
    }
    protected void btnGo_Click(object sender, EventArgs e)
    {
        try
        {
            string refno = GenerateCabRef();
            if (Session["TravelDate"].ToString() != null && Session["CardetailsId"].ToString() != null)
            {
                objPsgDtl.ScreenInd = blossom.InsertPassengerDetails;
                objPsgDtl.TravelDate = Session["TravelDate"].ToString();
                objPsgDtl.CarDetailsId = Convert.ToInt32(Session["CardetailsId"].ToString());
                objPsgDtl.Name = txtName.Text.ToString();
                objPsgDtl.Address = txtAddress.Text.ToString();
                objPsgDtl.City = txtCity.Text.ToString();
                objPsgDtl.State = DDLState.SelectedValue.ToString();
                objPsgDtl.ZipCode = txtZipCode.Text.ToString();
                objPsgDtl.Country = txtCountry.Text.ToString();
                objPsgDtl.EmailId = txtEMailId.Text.ToString();
                objPsgDtl.MobileNo = txtMobileNo.Text.ToString();
                objPsgDtl.LandMark = txtLandMark.Text.ToString();
                objPsgDtl.city_car = Session["CityName"].ToString();
                objPsgDtl.Status = "Blocked";
                objPsgDtl.CarName = CarName.Text.ToString();
                Session["Amount"] = BasicPrice.Text;
                //objPsgDtl.Status = txtStatus.Text.ToString();
                // objPsgDtl.BasicPrice =Convert.ToDouble(txtBasicPrice.Text);
                // objPsgDtl.BookingType = txtBookingType.Text.ToString();
                objPsgDtl.PickUpTime = DDLPickUpTime.SelectedValue.ToString();
                objPsgDtl.Basicfare = BasicPrice.Text;
                if (Session["UserId"] != null)
                {
                    if (Session["Role"].ToString() == "Agent")
                    {

                        Class1 objBal = new Class1();
                        DataSet objDataSet = new DataSet();
                        objBal.ScreenInd = Master123.gettopmarkup;
                        objBal.Agentid = Convert.ToInt32(Session["UserID"].ToString());
                        objBal.Type = "Cabs";
                        objDataSet = (DataSet)objBal.fnGetData();
                        string markUpAmount = "0";
                        ViewState["MarkUp"] = markUpAmount;
                        if (objDataSet != null)
                        {
                            if (objDataSet.Tables.Count > 0)
                            {
                                markUpAmount = objDataSet.Tables[0].Rows[0]["MarkUpAmount"].ToString();
                                ViewState["MarkUp"] = markUpAmount;
                            }
                        }

                        double actualfare = Convert.ToDouble(Session["Amount"]);
                        double totalfare = actualfare + Convert.ToDouble(markUpAmount);
                        objPsgDtl.TotalFare = totalfare.ToString();

                    }
                    else
                    {
                        objPsgDtl.TotalFare = BasicPrice.Text;
                    }
                }
                else
                {
                    objPsgDtl.TotalFare = BasicPrice.Text;
                }

                if (Session["UserId"] != null)
                {
                    objPsgDtl.AgentId = Session["UserId"].ToString();
                    objPsgDtl.AgentName = Session["UserName"].ToString();
                    objPsgDtl.Role = Session["Role"].ToString();
                }
                else
                {
                    objPsgDtl.Role = "Guest";
                }

                Session["refno"] = refno;
                objPsgDtl.ReferanceId = refno;
                objPsgDtl.CreatedBy = 1;
                 if (objPsgDtl.fnInsertRecord() == true)
                {
                    GetMail();
                    lblMsg.Text = "Record Inserted Successfully";
                    str = "SUCCESS";

                }
                 if (Session["UserId"]!=null)
                 {
                     if (Session["Role"].ToString() == "User")
                     {
                         if (str == "SUCCESS")
                         {

                             Response.Redirect("~/Pay.aspx?val=car", false);
                         }
                     }
                 }

                if(Session["UserId"]==null)
                {
                    if (str == "SUCCESS")
                    {

                        Response.Redirect("~/Pay.aspx?val=car", false);
                    }
                    else
                    {
                        lblText.Text = "Booking is failed.Please try later";
                    }
                }
                else if (Session["UserId"] != null && Session["Role"].ToString()=="Admin")
                {
                    if (Session["Role"].ToString() == "Admin")
                    {
                        Response.Redirect("~/CarTicket.aspx", false);
                    }
                }
                else
                {
                    if (Session["Role"] != null)
                    {
                        if (Session["Role"].ToString() == "Agent")
                        {
                            ClsBAL objBal = new ClsBAL();
                            DataSet dsBalance = objBal.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                            DataSet dsCommSlab = objBal.GetCommissionSlab(Session["Role"].ToString(), "Car", ""); // Change it
                            string commisionPercentage = string.Empty;

                            if (dsCommSlab != null)
                            {
                                if (dsCommSlab.Tables[0].Rows.Count > 0)
                                {
                                    commisionPercentage = dsCommSlab.Tables[0].Rows[0]["Commission"].ToString();// Change it
                                }
                                else
                                {
                                    commisionPercentage = "0";
                                }
                            }
                            else
                            {
                                commisionPercentage = "0";
                            }

                            string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                            string agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();
                            string TotalFare = BasicPrice.Text;
                            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))
                            {
                                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 = balanceAgent;
                                Session["Balance"] = balanceAgent;
                                Response.Redirect("~/CarTicket.aspx", false);

                            }
                            else
                            {

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

                                return;
                            }
                        }
                    }
                }

            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
            throw;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UserAgent.IndexOf("AppleWebKit") > 0) { Request.Browser.Adapters.Clear(); }
        ClsBAL objManabusBAL = new ClsBAL();
        //if (!IsPostBack)
        {
            string page = Request.Url.ToString().ToLower();
            //if (Session["UserID"] != null && Session["Role"] != null)
            //{
            if (Session["UserID"].ToString() != "INVALID USER"
                && Session["Role"].ToString() == "Agent")
            {
                if (Session["UserName"] != null)
                {
                    if (page.Contains("frmflightsavailability.aspx"))
                    {
                        pnlflights.Visible = true;
                        Menu1.Visible = false;
                        pnlhotels.Visible = false;
                    }
                    else if (page.Contains("default.aspx"))
                    {
                        pnlflights.Visible = false;
                        Menu1.Visible = true;
                        pnlhotels.Visible = false;
                    }
                    else if (page.Contains("selectbus.aspx") || page.Contains("custinfo.aspx") || page.Contains("redirectbus.aspx"))
                    {
                        pnlflights.Visible = false;
                        Menu1.Visible = true;
                        pnlhotels.Visible = false;
                    }
                    if (page.Contains("frmintflightsavailability.aspx"))
                    {
                        pnlflights.Visible = true;
                        Menu1.Visible = false;
                        pnlhotels.Visible = false;
                    }
                    if (page.Contains("hotels.aspx"))
                    {
                        pnlflights.Visible = false;
                        Menu1.Visible = false;
                        pnlhotels.Visible = true;
                    }
                    lblUsername.Text = "Welcome <b>" + Session["UserName"].ToString() + " </b>";

                    System.Data.DataSet ds = objManabusBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"]));

                    Session["Balance"] = ds.Tables[0].Rows[0]["Balance"].ToString();

                    Session["BusAgentStatus"] = ds.Tables[0].Rows[0]["Buses"].ToString();
                    Session["HotelsAgentStatus"] = ds.Tables[0].Rows[0]["Hotels"].ToString();
                    Session["RechargeAgentStatus"] = ds.Tables[0].Rows[0]["Recharge"].ToString();
                    Session["InterNationalFlightsAgentStatus"] = ds.Tables[0].Rows[0]["InterNationalFlights"].ToString();
                    Session["DomesticFlighsAgentStatus"] = ds.Tables[0].Rows[0]["DomesticFlighs"].ToString();

                    lblBalance.Text = "" + Session["Balance"].ToString();
                }
                if (!IsPostBack)
                {
                    imgAgentLogo.ImageUrl = "~/ActualImage.ashx?ID=" + Session["UserID"].ToString();
                    if (Session["View"].ToString() == "AgentView")
                    {
                        CustomerView.Visible = false; AgentView.Visible = true;
                    }
                    else if (Session["View"].ToString() == "CustomerView")
                    {
                        CustomerView.Visible = true; AgentView.Visible = false;
                    }
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx", false);
                Session["UserID"] = null;
            }
        }
        //else
        //{
        //    Response.Redirect("~/Default.aspx", false);
        //}
        // }
    }
Ejemplo n.º 5
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        ClsBAL objManabusBAL = new ClsBAL();
        objManabusBAL.userName = Convert.ToString(txtEmpLoginName.Text);
        objManabusBAL.password = Convert.ToString(txtEmpPassword.Text);

        if (objManabusBAL.CheckUser() == "Valid User")
        {
            if (Session["Role"] != null)
            {
                if (Session["Role"].ToString() == "Employee" || Session["Role"].ToString() == "BSD"||Session["Role"].ToString() == "CSE")
                {
                    System.Data.DataSet ds = objManabusBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                    Session["Balance"] = ds.Tables[0].Rows[0]["Balance"].ToString();
                    Session["View"] = "AgentView";
                    string ss = ds.Tables[0].Rows[0]["Status"].ToString();
                    if (ss.ToUpper().ToString() != "HOLD")
                    {
                        Response.Redirect("~/Users/AdminDb/AdminDb.aspx", false);
                    }
                    else
                    {
                        lblEmpMsg.Text = "Your account is on HOLD. Please contact the administrator.";
                        lblEmpMsg.ForeColor = System.Drawing.Color.Red;
                        Session["UserID"] = null;
                    }

                }
            }

        }
        else
        {
            lblEmpMsg.Text = "UserName/Password Incorrect.";
            lblEmpMsg.ForeColor = System.Drawing.Color.Red;
            Session["Role"] = null;
            Session["UserID"] = null;

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        objArzooHotelAPILayer = ArzooHotelFactoryManager.GetArzooHotelAPILayerObject();
        objArzooHotelAPILayer.UserName = ArzooHotelConstants.USERNAME;
        objArzooHotelAPILayer.UserId = ArzooHotelConstants.USERID;
        objArzooHotelAPILayer.UserType = ArzooHotelConstants.USERTYPE;
        objArzooHotelAPILayer.Password = ArzooHotelConstants.PASSWORD;
        objArzooHotelAPILayer.PartnerId = ArzooHotelConstants.PARTNERID;
        lblMsg.Text = "";
        this.Page.Title = "LoveJourney - Hotel - Ticket";
        if (!IsPostBack)
        {
            if (Session["HotelRefNo"] != null)
            {
                string strRefNo = Session["HotelRefNo"].ToString();

                HotelBAL obj = new HotelBAL();
                obj.ReferenceNo = strRefNo;
                DataSet ds = obj.GetHotelProvisional();

                if (ds != null)
                {
                    string hotelId = ""; string webService = ""; string ratePlanCode = ""; string roomTypeCode = "";
                    string cityName = ""; string allocavailResult = "";
                    string allocidResult = ""; string fromDate = ""; string toDate = ""; string roomType = "";
                    string wsKey = ""; string roomBasis = ""; string title = "";
                    string firstName = ""; string middleName = ""; string lastName = ""; int noOfRooms = 0;
                    int[] noOfAdultsInARoom = null; int[] noOfChildsInARoom = null;
                    int[] firstChildAge = null; int[] secondChildAge = null;
                    string roomStayCandidate = "";

                    DataRow dr = ds.Tables[0].Rows[0];

                    hotelId = dr["HotelId"].ToString();
                    webService = dr["WebService"].ToString();
                    ratePlanCode = dr["RatePlanType"].ToString();
                    roomTypeCode = dr["RoomTypeCode"].ToString();
                    cityName = dr["HotelCity"].ToString();
                    allocavailResult = dr["FromAllocation"].ToString();
                    allocidResult = dr["AllocationId"].ToString();

                    roomType = dr["RoomType"].ToString();
                    firstName = dr["FirstName"].ToString();
                    middleName = dr["MiddleName"].ToString();
                    lastName = dr["LastName"].ToString();
                    wsKey = dr["WsKey"].ToString();
                    roomBasis = dr["RoomBasis"].ToString();
                    title = dr["Title"].ToString();
                    noOfRooms = Convert.ToInt32(dr["NoOfRooms"].ToString());
                    roomStayCandidate = dr["RoomStayCandidate"].ToString();

                    string[] strValues = roomStayCandidate.Split(':');

                    fromDate = ConvertDate(strValues[1].ToString());
                    fromDate = fromDate.Replace('-', '/');
                    toDate = ConvertDate(strValues[2].ToString());
                    toDate = toDate.Replace('-', '/');

                    noOfRooms = Convert.ToInt32(strValues[3].ToString());

                    noOfAdultsInARoom = new int[noOfRooms];
                    noOfChildsInARoom = new int[noOfRooms];
                    firstChildAge = new int[noOfRooms];
                    secondChildAge = new int[noOfRooms];
                    int j = 0;
                    for (int i = 0; i < noOfRooms; i++)
                    {
                        if (i == 0)
                        {
                            j = 0;
                        }
                        else
                        {
                            j = 4 * i;
                        }

                        noOfAdultsInARoom[i] = Convert.ToInt32(strValues[4 + j].ToString());
                        noOfChildsInARoom[i] = Convert.ToInt32(strValues[5 + j].ToString());
                        firstChildAge[i] = Convert.ToInt32(strValues[6 + j].ToString());
                        secondChildAge[i] = Convert.ToInt32(strValues[7 + j].ToString());
                    }

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

                    DataSet dsCommSlabRet = objBAL.GetCommissionSlab(Session["Role"].ToString(), "Hotels","");

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

                    string agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();

                    string actualFare = dr["HotelTotalFare"].ToString().ToString();
                    string deductAmount = Convert.ToString(Convert.ToDouble(actualFare.ToString()) -
                        ((Convert.ToDouble(actualFare.ToString()) * Convert.ToDouble(commisionPercentage)) / 100));
                    string commisionFare = Convert.ToString(Convert.ToDouble(actualFare.ToString()) - Convert.ToDouble(deductAmount));

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

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

                        DataSet dsHotelBooking = objArzooHotelAPILayer.HotelBooking
                            (hotelId, webService, ratePlanCode, roomTypeCode, cityName, allocavailResult,
                            allocidResult, fromDate, toDate, roomType, wsKey, roomBasis, title, firstName, middleName, lastName, noOfRooms,
                            noOfAdultsInARoom, noOfChildsInARoom, firstChildAge, secondChildAge);

                        int provisionalId = Convert.ToInt32(dr["Id"].ToString());

                        if (!dsHotelBooking.Tables.Contains("HotelBooking"))
                        { lblMsg.Text = "Failed to book the ticket."; return; }

                        if (dsHotelBooking.Tables["HotelBooking"].Rows.Count == 0)
                        { lblMsg.Text = "Failed to book the ticket."; return; }

                        DataRow drr = dsHotelBooking.Tables["HotelBooking"].Rows[0];
                        wsKey = drr["wsKey"].ToString();

                        string extGuestTotal = drr["extGuestTotal"].ToString();
                        string roomTotal = drr["roomTotal"].ToString();
                        string serviceTaxTotal = drr["servicetaxTotal"].ToString();
                        string bookingStatus = drr["bookingstatus"].ToString();
                        string bookingRemarks = drr["bookingremarks"].ToString();
                        string bookingRefNo = drr["bookingref"].ToString();
                        string bookingTrn = drr["bookingTrn"].ToString();
                        string discount = drr["discount"].ToString();
                        string contactNumbers = drr["contactNumbers"].ToString();
                        string faxNumbers = drr["faxNumbers"].ToString();

                        if (drr["bookingstatus"].ToString() == "C")
                        {
                            string stt = "";
                            stt = InsertHotelBooking(provisionalId, wsKey, extGuestTotal, roomTotal, serviceTaxTotal, bookingStatus, bookingRemarks,
                                bookingRefNo, bookingTrn, discount, contactNumbers, faxNumbers, Convert.ToInt32(Session["UserID"].ToString()));
                            if (stt == "Success")
                            {
                                //lblMsg.Text = "Your ticket has been booked successfully. " + " BookingRefNo : " + Session["HotelRefNo"].ToString();

                                pnlTicket.Visible = true;
                                pnlOptions.Visible = true;

                                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(Session["DeductAmount_Agent"].ToString()),
                                          Convert.ToInt32(Session["UserID"].ToString()), strRefNo, Convert.ToDouble(Session["ActualFare_Agent"].ToString()),
                                          Convert.ToDouble(Session["CommisionFare_Agent"].ToString()), Convert.ToDouble(Session["CommisionPercentage_Agent"].ToString()));

                                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;

                                HotelBAL objTicket = new HotelBAL();
                                objTicket.ReferenceNo = strRefNo;
                                DataSet dsTicket = objTicket.GetHotelProvisional();

                                if (dsTicket != null)
                                {
                                    DataRow drTicketRow = dsTicket.Tables[0].Rows[0];
                                    lblHotelRefNo.Text = drTicketRow["ReferenceNo"].ToString();
                                    lblarzoorefno.Text = drTicketRow["BookingRefNo"].ToString();
                                    lblStatus.Text = drTicketRow["Status"].ToString();
                                    lblHotelName.Text = drTicketRow["HotelName"].ToString();

                                    lblAddress.Text = drTicketRow["HotelAddress"].ToString();

                                    lblHotelCity.Text = drTicketRow["HotelCity"].ToString();
                                    lblCheckIn.Text = drTicketRow["CheckInDate"].ToString();
                                    lblCheckOut.Text = drTicketRow["CheckOutDate"].ToString();
                                    lblRoomType.Text = drTicketRow["RoomType"].ToString();

                                    lblStar.Text = drTicketRow["HotelStar"].ToString() + " Star";
                                    lblNoOfRooms.Text = drTicketRow["NoOfRooms"].ToString();
                                    lblPaxGreaterThan12.Text = drTicketRow["NoOfAdults"].ToString();
                                    lblPaxLessThan12.Text = drTicketRow["NoOfChildren"].ToString();

                                    lblBookedDate.Text = drTicketRow["BookedDate"].ToString();
                                    lblHotelContactDetails.Text = drTicketRow["ContactNumbers"].ToString() + " , Fax Nos: " + drTicketRow["FaxNumbers"].ToString();

                                    lblTotalPrice.Text = drTicketRow["HotelTotalFare"].ToString() + "~" + drTicketRow["HotelTotlaFareDetails"].ToString();/////////////

                                    lblTitle.Text = drTicketRow["Title"].ToString();
                                    lblFirstName.Text = drTicketRow["FirstName"].ToString();
                                    lblMiddleName.Text = drTicketRow["MiddleName"].ToString();
                                    lblLastName.Text = drTicketRow["LastName"].ToString();
                                    lblMobileNo.Text = drTicketRow["MobileNumber"].ToString();
                                    lblEmailId.Text = drTicketRow["EmailId"].ToString();
                                    lblAdd.Text = drTicketRow["CustAddressLine"].ToString();
                                    lblState.Text = drTicketRow["CustState"].ToString();
                                    lblPinCode.Text = drTicketRow["CustZipCode"].ToString();

                                    lblCity.Text = drTicketRow["CustCity"].ToString();

                                    SMS();
                                    Mail(lblEmailId.Text.ToString());
                                }
                            }
                            else { lblMsg.Text = "Please Try Again."; }
                        }
                        else if (drr["bookingstatus"].ToString() == "E")
                        {
                            lblMsg.Text = "Failed to book the ticket.";
                        }

                    }
                    else
                    {
                        lblMsg.Text = "Your account does have the sufficient balance to book the ticket.";
                        pnlTicket.Visible = false;
                    }

                    Session["HotelRefNo"] = null;
                }
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string bookingRef = "";
            string emailId = "";
            string lastName = "";
            string webService = "";
            string startDate = "";
            string endDate = "";

            HotelBAL obj = new HotelBAL();
            obj.ReferenceNo = txtBookingRefNo.Text.ToString().Trim().ToString();
            DataSet ds = obj.GetHotelProvisional();

            if (ds == null)
            { lblMsg.Text = "Invalid reference number."; return; }
            if (ds.Tables.Count == 0)
            { lblMsg.Text = "Invalid reference number."; return; }
            if (ds.Tables[0].Rows.Count == 0)
            { lblMsg.Text = "Invalid reference number."; return; }

            DataRow dr = ds.Tables[0].Rows[0];

            emailId = dr["EmailId"].ToString();
            lastName = dr["LastName"].ToString();
            bookingRef = dr["BookingRefNo"].ToString();
            webService = dr["WebService"].ToString();
            startDate = ConvertDate(dr["CheckIn"].ToString());
            endDate = ConvertDate1(dr["CheckOut"].ToString());
            string status = dr["Status"].ToString();
            double hotelTotalFare = Convert.ToDouble(dr["HotelTotalFare"].ToString());

            if (status == "Cancelled") { lblMsg.Text = "Already this ticket has been cancelled."; return; }

            DataSet dsHotelCancellation = objArzooHotelAPILayer.HotelCancellation(emailId, lastName, bookingRef, webService, startDate, endDate);

            if (!dsHotelCancellation.Tables.Contains("HotelCancellation"))
            { lblMsg.Text = "Failed to cancel the ticket."; return; }

            DataTable dtCancellation = dsHotelCancellation.Tables["HotelCancellation"];
            if (dtCancellation.Rows.Count > 0)
            {
                DataRow item = dtCancellation.Rows[0];
                string cancellationId = item["cancellationId"].ToString();
                string refundTotalAmount = item["refundTotalAmount"].ToString();
                string cancellationAmount = item["cancellationAmount"].ToString();
                string success = item["success"].ToString();
                string error = item["error"].ToString();
                if (success != "" && cancellationId != "")
                {
                    lblMsg.Text = "Status: " + "Ticket has been cancelled successfully.";
                    string provisionalId = dr["ProvisionalId"].ToString();
                    string bookingId = dr["BookingId"].ToString();

                    double cancellationCharges = hotelTotalFare - Convert.ToDouble(refundTotalAmount);

                    InsertCancellaion(provisionalId, bookingId, Convert.ToDouble(refundTotalAmount),
                        cancellationCharges, Convert.ToInt32(Session["UserID"].ToString()), cancellationId);

                    objBAL = new ClsBAL();
                    objBAL.AdjustAgentBalance(txtBookingRefNo.Text.Trim().ToString(),
                        Convert.ToDouble(refundTotalAmount), Convert.ToDouble(cancellationCharges),
                        Convert.ToInt32(Session["UserID"].ToString()));

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

                    string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                    Label lbl = (Label)this.Master.FindControl("lblBalance");
                    lbl.Text = balance;
                    Session["Balance"] = balance;
                    txtBookingRefNo.Text = "";
                }
                else if (error != "") { lblMsg.Text = error.ToString(); }
                else { lblMsg.Text = "Failed to cancel the ticket."; }
            }

        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
Ejemplo n.º 8
0
    protected void DataCardRecharge()
    {
        try
        {
            getip();
            string MobileNumber, Provider, balance, Email;
            _objMasters = new clsMasters();
            _objMasters.ScreenInd = Masters.getagentDatacardrecharge;
            _objMasters.Parameter = "RequestID";
            _objMasters.RequestID = Session["Order_Id"].ToString();
            _objDataSet = new DataSet();
            _objDataSet = (DataSet)_objMasters.fnGetData();

            if (_objDataSet != null)
            {
                if (_objDataSet.Tables.Count > 0)
                {
                    if (_objDataSet.Tables[0].Rows.Count > 0)
                    {
                        MobileNumber = _objDataSet.Tables[0].Rows[0]["MobileNo"].ToString();
                        Provider = _objDataSet.Tables[0].Rows[0]["Provider_Name"].ToString();
                        balance = _objDataSet.Tables[0].Rows[0]["Amount"].ToString();
                        Email = _objDataSet.Tables[0].Rows[0]["E_Mail"].ToString();

                        //-----------Gettinh the commission of agent for a network-----

                        // _objMaster = new clsMasters();
                        _objMaster.ScreenInd = Masters.GetCommisionByNetwork;
                        _objMaster.NetworkName = Session["NetWorkName"].ToString();
                        if (Session["Role"].ToString() == "Agent")
                        {
                            _objMaster.Type = "AG";
                        }
                        _objMaster.UserID = Convert.ToInt32(Session["UserID"].ToString());
                        _objDataSet = (DataSet)_objMaster.fnGetData();
                        if (_objDataSet.Tables.Count > 0)
                        {
                            if (_objDataSet.Tables[0].Rows.Count > 0)
                            {
                                Commission = Convert.ToDecimal(_objDataSet.Tables[0].Rows[0]["AgentCommission"].ToString());
                            }
                        }

                        decimal rechargeAmount = Convert.ToDecimal(Session["RRechargeAmount"]);
                        decimal DeductAmountOnCommission = (rechargeAmount * Commission) / (100);
                        decimal deductamount = rechargeAmount - DeductAmountOnCommission;

                        //----------end-------
                        # region Mobile code

                        string all = "10118" + Session["Order_Id"] + Session["RProviderName"] + "|" + Session["RMobileNumber"] + "|" + Session["RRechargeAmount"] + "A8JW8FX7KQ7PY5ZT2S1V";

                        string pwhash = FormsAuthentication.HashPasswordForStoringInConfigFile(all, "sha1");

                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.payintegra.com/RechargeService");
                        request.Method = "POST";
                        request.ContentType = "application/x-www-form-urlencoded";
                        string postData = "PartnerId=10118&TransId=" + Session["Order_Id"] + "&Message=" + Session["RProviderName"] + "|" + Session["RMobileNumber"] + "|" + Session["RRechargeAmount"] + "&Hash=" + pwhash;
                        byte[] bytes = Encoding.UTF8.GetBytes(postData);
                        request.ContentLength = bytes.Length;

                        Stream requestStream = request.GetRequestStream();
                        requestStream.Write(bytes, 0, bytes.Length);

                        WebResponse response = request.GetResponse();
                        Stream stream = response.GetResponseStream();
                        StreamReader reader = new StreamReader(stream);

                        var result = reader.ReadToEnd();

                        string[] s = result.Split('|');

                        stream.Dispose();
                        reader.Dispose();

                        if (s[0].ToString().Trim() == "100" && s[4].ToString().Trim() == "Transaction Successful")
                        {
                            #region Insert Data into Database
                            //getstatus();
                            //if (Session["GetStatus"].ToString() == "Success ")
                            //{
                            AdminiBalance();
                            Session["TranscationId"] = s[1].ToString();
                            _objMasters = new clsMasters();

                            _objMasters.ScreenInd = Masters.getrecharge3;
                            _objMasters.Parameter = "update";
                            _objMasters.RequestID = Session["Order_Id"].ToString();
                            _objMasters.TransactionID = Convert.ToString(s[1].ToString());
                            Session["TransactionID"] = Convert.ToString(s[1].ToString());

                            _objMasters.Amount = Convert.ToDouble(balance);
                            _objMasters.UserID = Convert.ToInt32(Session["UserID"]);

                            _objMasters.AgentCommission = DeductAmountOnCommission;

                            _objMasters.Status = "SUCCESS";
                            Session["Status"] = "Recharge successfully";
                            _objMasters.IP = ipaddr;

                            _objMasters.A_Amount = Convert.ToDecimal(Session["FinalAdminBalance"].ToString());

                            if (_objMasters.fnUpdateRecord() == true)
                            {

                                Mpe1.Show();

                                lblMessage.Text = "Recharge has Been Success";

                                try
                                {
                                    string body = "<html xmlns='http://www.w3.org/1999/xhtml'><head><title></title></head><body>" +
                           "<table width='700' border='0' cellspacing='0' cellpadding='0' style='font-family: Verdana;font-size: smaller; margin-left: 1px; margin-right: 1px; padding-bottom: 10px;'><tr>" +
                           "<td valign='top' width='100%'>" +
                           "<table width='100%'><tr><td valign='top'" +
                          " &nbsp;<img src='http://lovejourney.in/images/ban.jpg' /></td> </tr></table> </td></tr>" + " <tr><td align='left' valign='top' style='height: 0px; background-color: #860f2b;'></td></tr>" +
                          "<tr><td align='left' valign='top' style='padding-left: 10px;'>Dear User, </td></tr>" +
                          "<tr><td align='left' valign='top' style='padding-left: 10px;'>Your TransactionID .<span style='font-weight: 600;'>" + Session["TransactionID"] + " " + "& Your request Id is " + "" + Session["Order_Id"] + " </span></td></tr>" +
                          "<tr><td><table><tr><td align='right' valign='top' style='padding-right: 100px; background-color: #F1F1F1'><span style='color: #860f2b; font-weight: 600;'> Mobile Number:</span>" + MobileNumber + "</td>" +
                          "<td align='right' valign='top' style='padding-right: 100px; background-color: #F1F1F1'><span style='color: #860f2b; font-weight: 600;'>Amount:</span>" + balance + "</td></tr></table></td></tr>" +
                           "<tr><td align='left' width='100%' valign='top'><table><tr><td align='center' width='100%' valign='top' style='background-color: #860f2b; color: White;' colspan='2'><b>Contact Us</b></td></tr>" +
                           "<tr><td align='left' valign='top' style='background-color: #EFEFEF;'><table><tr><td align='right' valign='top'><span style='color: #860f2b;'>Support</span> </td>  " + "<td align='left' valign='top'>  &nbsp;Visit our Knowledge Base / FAQs for quick answers Log a query or problem at  My Helpdesk </td></tr> " +
                           "<tr><td align='right' valign='top'></td>&quot;</tr></table></td>" +
                         "<td align='left' valign='top' style='background-color: #EFEFEF;'><table><tr><td align='left' valign='top'> <span style='color: #860f2b;'>Sales Support</span></td> " +
                         "<td align='left' valign='top'> </td></tr>" +
                          "<tr><td align='left' valign='top' style='padding-left: 20px;'></td></tr>" +
                          "<tr><td align='left' valign='top' style='padding-left: 20px; background-color: #860f2b color: White;'></td></tr>" +
                          "</table></body></html>" +
                          "<br />Again, we thank you for registering with <b>www.lovejourney.in</b> and please " +
                           "do not hesitate to write to us at <a href='mailto:[email protected]'>Mail</a>" + "if you have any questions.<br /><br />Best Regards,<br /><a href='http://www.lovejourney.in'>lovejourney.in</a> " + "<br /><br />";

                                    MailSender.SendEmail("*****@*****.**", "*****@*****.**", "*****@*****.**", "LoveJourney-Recharge", body);

                                }
                                catch (Exception ex)
                                {
                                    //LogError("redirect.aspx", "Mail", DateTime.Now, ex.Message.ToString());
                                   // Response.Redirect("Error.aspx", false);

                                }

                                try
                                {
                                    //string strUrl = "http://sms.i2space.in/WebServiceSMS.aspx?User=i2space1&passwd=smsc&mobilenumber=" + MobileNumber +
                                    //"&message= Thank You for using lovejourney.in to Recharge Mobile no" + MobileNumber + " for Rs" + " " + balance + "& your order Num is" + "" + Session["TransactionID"] + "" + "for Queries ,Email us at [email protected]" +
                                    //"&sid=LoveJourney&mtype=N";
                                    //HttpWebRequest oReq1 = null;
                                    //HttpWebResponse oRes1 = null;
                                    //StreamReader oStream1 = null;
                                    //oReq1 = (HttpWebRequest)WebRequest.Create(strUrl);
                                    //oReq1.Method = "GET";
                                    //oReq1.Timeout = 10000;
                                    //oRes1 = (HttpWebResponse)oReq1.GetResponse();
                                    //oStream1 = new StreamReader(oRes1.GetResponseStream(), Encoding.GetEncoding(1252));
                                    //string strMessage1 = oStream1.ReadToEnd().ToString();
                                }
                                catch (ArgumentException ex)
                                {
                                    //LogError("redirect.aspx", "sms", DateTime.Now, ex.Message.ToString());
                                  //  Response.Redirect("Error.aspx", false);
                                }

                                //_objMaster = new clsMasters();
                                //_objMaster.ScreenInd = Masters.deductagentbalance;
                                //_objMaster.UserID = Convert.ToInt32(Session["UserID"]);
                                //_objMaster.A_Amount = deductamount;
                                //_objMaster.fnUpdateRecord();

                                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble(deductamount),
                                      Convert.ToInt32(Session["UserID"].ToString()), Session["TransactionID"].ToString().Trim(), Convert.ToDouble(Session["RRechargeAmount"].ToString()),
                                      Convert.ToDouble(DeductAmountOnCommission), Convert.ToInt32(Session["CommisionPercentage_Agent"].ToString()));

                                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 = balanceAgent;
                                Session["Balance"] = balanceAgent;

                                Response.Redirect("~/Agent/Recharge/RechargeSucces.aspx", false);

                            #endregion
                            }
                            // }

                        }
                        else
                        {
                            AdminiBalance();

                            _objMasters = new clsMasters();

                            _objMasters.ScreenInd = Masters.getrecharge3;
                            _objMasters.Parameter = "update";
                            _objMasters.RequestID = Session["Order_Id"].ToString();
                            _objMasters.TransactionID = Convert.ToString(s[1].ToString());
                            Session["TransactionID"] = Convert.ToString(s[1].ToString());

                            _objMasters.Amount = Convert.ToDouble(balance);
                            _objMasters.UserID = Convert.ToInt32(Session["UserID"]);
                            _objMasters.Status = "Failure";
                            Session["Status"] = "Recharge Failure";

                            _objMasters.A_Amount = Convert.ToDecimal(Session["FinalAdminBalance"].ToString());

                            _objMasters.IP = ipaddr;

                            Session["errorcode"] = s[0].ToString();
                            Session["errorDecsription"] = s[4].ToString();

                            _objMasters.fnUpdateRecord();

                            Response.Redirect("~/Agent/Recharge/Failure.aspx", false);
                        }
                    }
                }

                else
                {
                    Mpe1.Show();
                    lblMessage.Text = "Recharge Has Been Failed Please Try Again Later";

                }
                        #endregion
            }
            else
            {
                Mpe1.Show();
                lblMessage.Text = "Recharge Has Been Failed Please Try Again Later";

            }
        }
        catch (Exception ex)
        {
            //LogError("Masters/Recharge.aspx", "DataCardRecharge", DateTime.Now, ex.Message.ToString());
            throw ex;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UserAgent.IndexOf("AppleWebKit") > 0) { Request.Browser.Adapters.Clear(); }
        ClsBAL objManabusBAL = new ClsBAL();
        //if (!IsPostBack)
        {
            if (Session["UserID"] != null && Session["Role"] != null)
            {
                if (Session["UserID"].ToString() != "INVALID USER"
                    && Session["Role"].ToString() == "Agent")
                {
                    if (Session["UserName"] != null)
                    {
                        lblUsername.Text = "Welcome <b>" + Session["UserName"].ToString() + " </b>";

                        System.Data.DataSet ds = objManabusBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));

                        Session["Balance"] = ds.Tables[0].Rows[0]["Balance"].ToString();

                        Session["BusAgentStatus"] = ds.Tables[0].Rows[0]["Buses"].ToString();
                        Session["HotelsAgentStatus"] = ds.Tables[0].Rows[0]["Hotels"].ToString();
                        Session["RechargeAgentStatus"] = ds.Tables[0].Rows[0]["Recharge"].ToString();
                        Session["InterNationalFlightsAgentStatus"] = ds.Tables[0].Rows[0]["InterNationalFlights"].ToString();
                        Session["DomesticFlighsAgentStatus"] = ds.Tables[0].Rows[0]["DomesticFlighs"].ToString();

                        lblBalance.Text = "" + Session["Balance"].ToString();
                    }
                    if (!IsPostBack)
                    {
                        imgAgentLogo.ImageUrl = "~/ActualImage.ashx?ID=" + Session["UserID"].ToString();
                        if (Session["View"].ToString() == "AgentView")
                        {
                            CustomerView.Visible = false; AgentView.Visible = true;
                        }
                        else if (Session["View"].ToString() == "CustomerView")
                        {
                            CustomerView.Visible = true; AgentView.Visible = false;
                        }
                    }
                }
                else
                {
                    Response.Redirect("~/Default.aspx", false);
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx", false);
            }
        }
    }
    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)
        {

        }
    }
Ejemplo n.º 11
0
 DataSet GetAgentByUserId(int id)
 {
     try
     {
         ClsBAL objManabusBal = new ClsBAL();
         return objManabusBal.GetAgentByUserId(id);
     }
     catch (Exception ex)
     {
         lblMsg.InnerHtml = ex.Message;
         throw;
     }
 }
    protected void CancelKesineniTickets(string CancelType, string SeatNos)
    {
        try
        {
            if (ViewState["dsticketdetails"] != null)
            {
                DataTable dt = (DataTable)ViewState["dsticketdetails"];
                int BookingId = Convert.ToInt32(dt.Rows[0]["BookingId"].ToString());
                int tentativeId = Convert.ToInt32(dt.Rows[0]["TentativeId"].ToString());
                string EmailId = dt.Rows[0]["EmailId"].ToString();
                string cancelllationId = dt.Rows[0]["CancellationId"].ToString();
                string CancelledSaets = dt.Rows[0]["CancelledSeats"].ToString();
                string pnrNumberKesineni = dt.Rows[0]["PNRNumber"].ToString().Trim().ToString();
                string firstNameKesineni = dt.Rows[0]["FullName"].ToString();
                string lastNameKesineni = dt.Rows[0]["FullName"].ToString();
                DateTime DOJ = Convert.ToDateTime(dt.Rows[0]["DateOfJourney"].ToString());
                string dateOfJourneyKesineni = DOJ.ToString("MM/dd/yyyy");
                string seatNumberListKesineni = dt.Rows[0]["SeatNos"].ToString();

                if (CancelType == "Total Cancellation")
                {
                    DataSet dsKesineni = objKesineniAPILayer.CancelTickets(pnrNumberKesineni, firstNameKesineni, lastNameKesineni,
             dateOfJourneyKesineni, SeatNos);

                    #region total Cancellation
                    if (dsKesineni != null)
                    {
                        if (dsKesineni.Tables[0].Rows.Count > 0 && dsKesineni.Tables[0].Columns.Count > 2)
                        {
                            double grandTotalRefund = Convert.ToDouble(dsKesineni.Tables[0].Rows[0]["GrandTotalRefunded"].ToString());
                            double cancellationCharges = Convert.ToDouble(dsKesineni.Tables[0].Rows[0]["CancellationCharges"].ToString());

                            DataSet dsKesineni1 = objKesineniAPILayer.ConfirmCancelTickets(pnrNumberKesineni, firstNameKesineni,
                             lastNameKesineni, dateOfJourneyKesineni, SeatNos);

                            if (dsKesineni1 != null)
                            {
                                if (dsKesineni1.Tables.Count > 0)
                                {
                                    if (dsKesineni1.Tables[0].Columns.Count > 1 && dsKesineni1.Tables[0].Rows.Count > 0)
                                    {
                                        AddCancellation(BookingId, tentativeId, SeatNos, EmailId, Convert.ToString(grandTotalRefund), Convert.ToString(Convert.ToDouble(grandTotalRefund) + Convert.ToDouble(cancellationCharges)), "", 0);

                                        objBAL = new ClsBAL();
                                        objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                            Convert.ToDouble(grandTotalRefund), Convert.ToDouble(cancellationCharges),
                                            Convert.ToInt32(Session["UserID"]));

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

                                        string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                                        Label lbl = (Label)this.Master.FindControl("lblBalance");
                                        lbl.Text = balance;
                                        Session["Balance"] = balance;
                                        txtEmailID.Text = txtMBRefNo.Text = "";
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        lblMsg.ForeColor = System.Drawing.Color.Red;
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    lblMsg.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                            else
                            {
                                lblMsg.Text = "Ticket cancelled failed. Try Again";
                                lblMsg.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }
                    #endregion
                }
                else if (CancelType == "Partial Cancellation")
                {
                    DataSet dsKesineni = objKesineniAPILayer.CancelTickets(pnrNumberKesineni, firstNameKesineni, lastNameKesineni,
              dateOfJourneyKesineni, SeatNos);

                    #region PartialCancellation
                    if (dsKesineni != null)
                    {
                        if (dsKesineni.Tables[0].Rows.Count > 0 && dsKesineni.Tables[0].Columns.Count > 2)
                        {
                            double grandTotalRefundp = Convert.ToDouble(dsKesineni.Tables[0].Rows[0]["GrandTotalRefunded"].ToString());
                            double cancellationChargesp = Convert.ToDouble(dsKesineni.Tables[0].Rows[0]["CancellationCharges"].ToString());

                            DataSet dsKesineni1 = objKesineniAPILayer.ConfirmCancelTickets(pnrNumberKesineni, firstNameKesineni,
                             lastNameKesineni, dateOfJourneyKesineni, SeatNos);
                            if (dsKesineni1 != null)
                            {
                                if (dsKesineni1.Tables.Count > 0)
                                {
                                    if (dsKesineni1.Tables[0].Columns.Count > 1 && dsKesineni1.Tables[0].Rows.Count > 0)
                                    {
                                        if (cancelllationId != "" && CancelledSaets != "")
                                        {
                                            UpdateCancelltion(Convert.ToInt32(cancelllationId), SeatNos, Convert.ToString(grandTotalRefundp), Convert.ToString(cancellationChargesp));
                                        }
                                        else if (cancelllationId == "" && CancelledSaets == "")
                                        {
                                            AddCancellation(BookingId, tentativeId, SeatNos, EmailId, Convert.ToString(grandTotalRefundp), Convert.ToString(cancellationChargesp), "", 0);
                                        }
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        lblMsg.ForeColor = System.Drawing.Color.Red;
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    lblMsg.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                            else
                            {
                                lblMsg.Text = "Ticket cancelled failed. Try Again";
                                lblMsg.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }
                    #endregion
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void CancelBitlaTickets(string CancelType, string SeatNos)
    {
        try
        {
            if (ViewState["dsticketdetails"] != null)
            {
                DataTable dt = (DataTable)ViewState["dsticketdetails"];
                int BookingId = Convert.ToInt32(dt.Rows[0]["BookingId"].ToString());
                int tentativeId = Convert.ToInt32(dt.Rows[0]["TentativeId"].ToString());
                string EmailId = dt.Rows[0]["EmailId"].ToString();
                string Name = dt.Rows[0]["FullName"].ToString();
                string ticketNumberBitla = dt.Rows[0]["PNRNumber"].ToString();
                string seatNumbersBitla = dt.Rows[0]["SeatNos"].ToString();
                string cancelllationId = dt.Rows[0]["CancellationId"].ToString();
                string CancelledSaets = dt.Rows[0]["CancelledSeats"].ToString();

                if (CancelType == "Total Cancellation")
                {
                    objBitlaAPILayer.TicketNumber = ticketNumberBitla;
                    objBitlaAPILayer.SeatNumbers = SeatNos;
                    DataSet dsBitla = objBitlaAPILayer.IsTicketCancellable();

                    #region Cancellation
                    if (dsBitla != null)
                    {
                        if (dsBitla.Tables[0].Rows.Count > 0 && dsBitla.Tables[0].Columns.Count > 2)
                        {
                            string refundAmount = dsBitla.Tables[0].Rows[0]["refund_amount"].ToString();
                            string cancellationCharges = dsBitla.Tables[0].Rows[0]["cancellation_charges"].ToString();
                            if (dsBitla.Tables[0].Rows[0]["is_cancellable"].ToString().ToUpper().ToString() == "TRUE")
                            {
                                objBitlaAPILayer.TicketNumber = ticketNumberBitla;
                                DataSet dsBitla1 = objBitlaAPILayer.CancelTicket();

                                if (dsBitla1 != null)
                                {
                                    if (dsBitla1.Tables.Count > 0)
                                    {
                                        if (dsBitla1.Tables[0].Columns.Count > 1 && dsBitla1.Tables[0].Rows.Count > 0)
                                        {
                                            AddCancellation(BookingId, tentativeId, SeatNos, EmailId, refundAmount, Convert.ToString(Convert.ToDouble(refundAmount) + Convert.ToDouble(cancellationCharges)), "Bitla", hour);

                                            Mail(dt.Rows[0]["EmailId"].ToString(), dt.Rows[0]["PGMBRefNo"].ToString());

                                            objBAL = new ClsBAL();
                                            objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                                Convert.ToDouble(refundAmount), Convert.ToDouble(cancellationCharges),
                                                Convert.ToInt32(Session["UserID"]));

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

                                            string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                                            Label lbl = (Label)this.Master.FindControl("lblBalance");
                                            lbl.Text = balance;
                                            Session["Balance"] = balance;
                                            txtEmailID.Text = txtMBRefNo.Text = "";
                                        }
                                        else
                                        {
                                            lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        }
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                }
                            }
                            else { lblMsg.Text = "Already cancelled "; }
                        }
                        else
                        {
                            lblMsg.Text = "Already cancelled ";
                        }
                    }
                    #endregion
                }
                else if (CancelType == "Partial Cancellation")
                {
                    objBitlaAPILayer.TicketNumber = ticketNumberBitla;
                    objBitlaAPILayer.SeatNumbers = SeatNos;
                    DataSet dsBitla = objBitlaAPILayer.IsTicketCancellable();

                    #region PartialCancellation
                    if (dsBitla != null)
                    {
                        if (dsBitla.Tables[0].Rows.Count > 0 && dsBitla.Tables[0].Columns.Count > 2)
                        {
                            string refundAmount = dsBitla.Tables[0].Rows[0]["refund_amount"].ToString();
                            string cancellationCharges = dsBitla.Tables[0].Rows[0]["cancellation_charges"].ToString();
                            if (dsBitla.Tables[0].Rows[0]["is_cancellable"].ToString() == "true")
                            {
                                objBitlaAPILayer.TicketNumber = ticketNumberBitla;
                                DataSet dsBitla1 = objBitlaAPILayer.CancelPartialTicket();
                                if (dsBitla1 != null)
                                {
                                    if (dsBitla1.Tables.Count > 0)
                                    {
                                        if (dsBitla1.Tables[0].Columns.Count > 1 && dsBitla1.Tables[0].Rows.Count > 0)
                                        {
                                            if (cancelllationId != "" && CancelledSaets != "")
                                            {
                                                UpdateCancelltion(Convert.ToInt32(cancelllationId), SeatNos, refundAmount, cancellationCharges);
                                            }
                                            else if (cancelllationId == "" && CancelledSaets == "")
                                            {
                                                AddCancellation(BookingId, tentativeId, SeatNos, EmailId, refundAmount, Convert.ToString(Convert.ToDouble(refundAmount) + Convert.ToDouble(cancellationCharges)), "Bitla", hour);
                                            }
                                        }
                                        else
                                        {
                                            lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        }
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                }
                            }
                        }
                        else
                        {
                            lblMsg.Text = "Already cancelled ";
                        }
                    }
                    #endregion
                }
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["UserID"] != null)
            {
                DataSet dsticketdetails = CheckTicketID();
                if (CheckStatus)
                {
                    if (dsticketdetails != null)
                    {
                        int BookingId = Convert.ToInt32(dsticketdetails.Tables[0].Rows[0]["BookingId"].ToString());
                        int tentativeId = Convert.ToInt32(dsticketdetails.Tables[0].Rows[0]["TentativeId"].ToString());
                        string EmailId = dsticketdetails.Tables[0].Rows[0]["EmailId"].ToString();
                        string Name = dsticketdetails.Tables[0].Rows[0]["FullName"].ToString();
                        string seatnumbers = dsticketdetails.Tables[0].Rows[0]["SeatNos"].ToString();
                        string totalfareabhi = dsticketdetails.Tables[0].Rows[0]["TotalFare"].ToString();
                        string ticketNumberBitla = dsticketdetails.Tables[0].Rows[0]["PNRNumber"].ToString();

                        string BoardingPointName = dsticketdetails.Tables[0].Rows[0]["BoardingPointName"].ToString();
                        string DateofJourney = dsticketdetails.Tables[0].Rows[0]["DateOfJourney"].ToString();
                        string[] dd = DateofJourney.Split(' ');
                        string[] bd = BoardingPointName.Split('-');
                        string dateofjourney = dd[0];
                        string datenow = dd[0] + "" + bd[1];
                        string APIName = dsticketdetails.Tables[0].Rows[0]["APIName"].ToString();
                        lblCode.Text = GenerateRandomCode();
                        TimeSpan s = DateTime.Parse(datenow) - DateTime.Now;

                        if (s.Days > 0)
                        {
                            dayhours = Convert.ToInt32(s.Days) * 24;
                        }
                        if (s.Minutes > 30)
                        {
                            hour = dayhours + s.Hours + 1;
                        }
                        if (s.Minutes <= 30)
                        {
                            hour = dayhours + s.Hours;
                        }
                        if (hour > 0)
                        {
                            Session["NameMail"] = Name;
                            Session["EmailIdMail"] = EmailId;

                            #region Kesineni
                            if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "Kesineni")
                            {
                                ViewState["APIName"] = "Kesineni";
                                rbtnlstCancelType.Visible = gvPartialCancellation.Visible = btnConfrmCancel.Visible = false;
                                gvPartialCancellation.DataSource = dsticketdetails.Tables[1];
                                gvPartialCancellation.DataBind();
                                ViewState["dsticketdetails"] = dsticketdetails.Tables[0];
                                btnConfrmCancel_Click(sender, e);
                            }
                            #endregion

                            #region AbhiBus
                            else if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "SVR" || dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "KAVERI" || dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "RAJESH" || dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "SAIANJANA" || dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "KALLADA")
                            {
                                string ticketNumberAbhiBus = dsticketdetails.Tables[0].Rows[0]["PNRNumber"].ToString();
                                //cancelTicket
                                ClientAPIList objClientAPIList = new ClientAPIList();
                                objClientAPIList = GetAPIProvidersList(ConsumerKey, ConsumerSecret);
                                ClientAPIDetails objClientAPIDetails = objClientAPIList.SingleOrDefault(element => element.ProviderName == dsticketdetails.Tables[0].Rows[0]["APIName"].ToString()); //objClientAPIList.ElementAt(resultSet - 1)
                                LJ.CLB.Buses.AbhibusAPI obj = new LJ.CLB.Buses.AbhibusAPI();
                                DataTable dtAbhiBus = obj.cancelTicket(objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey, ticketNumberAbhiBus);

                                if (dtAbhiBus != null)
                                {
                                    if (dtAbhiBus.Rows.Count > 0)
                                    {
                                        if (dtAbhiBus.Rows[0]["status"].ToString().ToUpper().Trim().ToString() == "SUCCESS")
                                        {
                                            string totalRefundAmount = dtAbhiBus.Rows[0]["total_refund_amount"].ToString();
                                            string canpercentage = dtAbhiBus.Rows[0]["cancellation_parcentage"].ToString();
                                            string[] canindec = canpercentage.Split('%');
                                            double cancelcharges = Convert.ToDouble(totalfareabhi) * (Convert.ToDouble(canindec[0].ToString()) / 100);

                                            AddCancellation(BookingId, tentativeId, seatnumbers, EmailId,
                                                Convert.ToString(Convert.ToDouble(totalfareabhi) - cancelcharges), Convert.ToString(totalfareabhi), APIName, hour);
                                            Mail(dsticketdetails.Tables[0].Rows[0]["EmailId"].ToString(), dsticketdetails.Tables[0].Rows[0]["PGMBRefNo"].ToString());
                                            objBAL = new ClsBAL();
                                            objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                                Convert.ToDouble(Convert.ToDouble(totalfareabhi) - cancelcharges), Convert.ToDouble(cancelcharges),
                                                Convert.ToInt32(Session["UserID"]));

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

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

                                        }
                                        else
                                        {
                                            lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        }
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                }
                            }
                            #endregion

                            #region Kallada
                            if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "kallada")
                            {
                                string ticketNumberkallada = dsticketdetails.Tables[0].Rows[0]["PNRNumber"].ToString();
                                DataTable dtkallada = objkalladaAPILayer.CancellationConfirmation(ticketNumberkallada);
                                if (dtkallada != null)
                                {
                                    if (dtkallada.Rows.Count > 0)
                                    {
                                        if (dtkallada.Rows[0]["status"].ToString() == "Success")
                                        {
                                            string totalRefundAmount = dtkallada.Rows[0]["total_refund_amount"].ToString();
                                            string canpercentage = dtkallada.Rows[0]["cancellation_parcentage"].ToString();
                                            string[] canindec = canpercentage.Split('%');
                                            double cancelcharges = Convert.ToDouble(totalfareabhi) * (Convert.ToDouble(canindec[0].ToString()) / 100);

                                            DataTable dtKallada1 = objkalladaAPILayer.TicketCancellation(ticketNumberkallada);
                                            if (dtKallada1.Rows.Count > 0 && dtKallada1.Columns.Count > 1)
                                            {
                                                if (dtKallada1.Rows[0]["status"].ToString().ToUpper().Trim().ToString() != "FAIL")
                                                {
                                                    AddCancellation(BookingId, tentativeId, seatnumbers, EmailId,
                                                        Convert.ToString(Convert.ToDouble(totalfareabhi) - cancelcharges), Convert.ToString(totalfareabhi), APIName, hour);

                                                    objBAL = new ClsBAL();
                                                    objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                                        Convert.ToDouble(Convert.ToDouble(totalfareabhi) - cancelcharges), Convert.ToDouble(cancelcharges),
                                                        Convert.ToInt32(Session["UserID"]));
                                                }
                                                else { lblMsg.Text = "Ticket cancelled failed."; }

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

                                                string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                                                Label lbl = (Label)this.Master.FindControl("lblBalance");
                                                lbl.Text = balance;
                                                Session["Balance"] = balance;
                                                txtEmailID.Text = txtMBRefNo.Text = "";
                                            }
                                        }
                                        else
                                        {
                                            lblMsg.Text = "Ticket cancelled failed. Try Again";
                                            lblMsg.ForeColor = System.Drawing.Color.Red;
                                        }
                                    }
                                    else
                                    {
                                        lblMsg.Text = "Ticket cancelled failed. Try Again";
                                        lblMsg.ForeColor = System.Drawing.Color.Red;
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Ticket cancelled failed. Try Again";
                                    lblMsg.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                            #endregion

                            #region Bitla
                            else if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "BITLA")
                            {
                                ViewState["APIName"] = "Bitla";
                                rbtnlstCancelType.Visible = gvPartialCancellation.Visible = btnConfrmCancel.Visible = false;
                                gvPartialCancellation.DataSource = dsticketdetails.Tables[1];
                                gvPartialCancellation.DataBind();
                                ViewState["dsticketdetails"] = dsticketdetails.Tables[0];
                                btnConfrmCancel_Click(sender, e);
                            }
                            #endregion

                            #region TicketGoose
                            else if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "TICKETGOOSE")
                            {
                                ViewState["APIName"] = "TicketGoose";
                                string ticketNumber = dsticketdetails.Tables[0].Rows[0]["PNRNumber"].ToString();
                                string[] seatNos = dsticketdetails.Tables[0].Rows[0]["SeatNos"].ToString().Split(',');
                                DataTable dt = objTicketGooseAPILayer.CancelTicket(ticketNumber, seatNos);
                                if (dt != null)
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        if (dt.Rows[0]["Status"].ToString() == "Success")
                                        {
                                            DataTable dtt = objTicketGooseAPILayer.ConfirmTicketCancellation(ticketNumber, seatNos);
                                            if (dtt != null)
                                            {
                                                if (dtt.Rows.Count > 0)
                                                {
                                                    if (dtt.Rows[0]["Status"].ToString() == "Success")
                                                    {
                                                        string refAmount = dtt.Rows[0]["refundAmount"].ToString();
                                                        AddCancellation(BookingId, tentativeId, seatnumbers, EmailId,
                                                       refAmount, Convert.ToString(Convert.ToDouble(totalfareabhi)), APIName, hour);

                                                        Mail(dsticketdetails.Tables[0].Rows[0]["EmailId"].ToString(), dsticketdetails.Tables[0].Rows[0]["PGMBRefNo"].ToString());

                                                        objBAL = new ClsBAL();
                                                        objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                                            Convert.ToDouble(refAmount), Convert.ToDouble(Convert.ToDouble(totalfareabhi) - Convert.ToDouble(refAmount)),
                                                            Convert.ToInt32(Session["UserID"]));
                                                    }
                                                    else { lblMsg.Text = "Ticket cancelled failed. Try Again"; }

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

                                                    string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                                                    Label lbl = (Label)this.Master.FindControl("lblBalance");
                                                    lbl.Text = balance;
                                                    Session["Balance"] = balance;
                                                    txtEmailID.Text = txtMBRefNo.Text = "";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region EasyBus

                            else if (dsticketdetails.Tables[0].Rows[0]["APIName"].ToString() == "EASYBUS")
                            {
                                string ticketNumberEasybus = dsticketdetails.Tables[0].Rows[0]["PNRNumber"].ToString();
                                //cancelTicket
                                ClientAPIList objClientAPIList = new ClientAPIList();
                                objClientAPIList = GetAPIProvidersList(ConsumerKey, ConsumerSecret);
                                ClientAPIDetails objClientAPIDetails = objClientAPIList.SingleOrDefault(element => element.ProviderName == dsticketdetails.Tables[0].Rows[0]["APIName"].ToString()); //objClientAPIList.ElementAt(resultSet - 1)
                                LJ.CLB.Buses.EasybusAPI obj = new LJ.CLB.Buses.EasybusAPI();
                                DataTable dtEasybus = obj.cancelTicket(objClientAPIDetails.APIURL, objClientAPIDetails.ConsumerKey, ticketNumberEasybus, seatnumbers, dateofjourney);
                                if (dtEasybus != null)
                                {
                                    if (dtEasybus.Rows.Count > 0)
                                    {
                                        if (dtEasybus.Rows[0]["Message"].ToString() == "Your Ticket has been cancelled")
                                        {

                                            string totalRefundAmount = totalfareabhi;
                                            string canpercentage = "10";
                                            string[] canindec = canpercentage.Split('%');
                                            double cancelcharges = Convert.ToDouble(totalfareabhi) * (Convert.ToDouble(canindec[0].ToString()) / 100);

                                            AddCancellation(BookingId, tentativeId, seatnumbers, EmailId,
                                               Convert.ToString(Convert.ToDouble(totalfareabhi) - cancelcharges), Convert.ToString(totalfareabhi), APIName, hour);
                                            Mail(dsticketdetails.Tables[0].Rows[0]["EmailId"].ToString(), dsticketdetails.Tables[0].Rows[0]["PGMBRefNo"].ToString());
                                            objBAL = new ClsBAL();
                                            objBAL.AdjustAgentBalance(txtMBRefNo.Text.Trim().ToString(),
                                                Convert.ToDouble(totalRefundAmount), Convert.ToDouble(Convert.ToDouble(totalfareabhi) - Convert.ToDouble(totalRefundAmount)),
                                                Convert.ToInt32(Session["UserID"]));
                                            DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"]));

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

                                        }
                                    }
                                }

                            }
                            #endregion
                        }
                        else
                        {
                            tdmsg.Visible = true;
                            //tdmsg.Style.Add("background-color:#E77471;", "");
                            lblMainMsg.Text = "Invalid Ref No.";
                            lblMainMsg.ForeColor = System.Drawing.Color.Maroon;
                            txtMBRefNo.Text = "";

                        }
                    }
                    else
                    {
                        tdmsg.Visible = true;
                        //tdmsg.Style.Add("background-color:#E77471;", "");
                        lblMainMsg.Text = "Invalid Ref No.";
                        lblMainMsg.ForeColor = System.Drawing.Color.Maroon;
                        txtMBRefNo.Text = "";

                    }
                }
                else
                {
                    tdmsg.Visible = true;
                    //tdmsg.Style.Add("background-color:#E77471;", "");
                    lblMainMsg.Text = "Invalid Ref No.";
                    lblMainMsg.ForeColor = System.Drawing.Color.Maroon;
                    txtMBRefNo.Text = "";
                }
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
            throw ex;
        }
    }
Ejemplo n.º 15
0
    protected void btnProceedToPayment_Click(object sender, EventArgs e)
    {
        try
        {
            if (cbxAgree.Checked == false)
            {
                lblMsg.Text = "please check the Terms & conditions.";
                return;
            }
            int? createdBy = null;
            if (Session["UserID"] != null) { createdBy = Convert.ToInt32(Session["UserID"].ToString()); }
            else { createdBy = 0; }

            if (Session["RedBusBookingDetails"] != null)
            {
                BookingDetails = (String[])Session["RedBusBookingDetails"];
                // string gridviewdata = client.getBoardingPoint(BookingDetails[4].Split('~')[1]);
                // DataTable dtOnwardBoardingInfo = convertJsonStringToDataSet(gridviewdata).Tables[0];
                string boardinginf = BookingDetails[4].ToString();
                string strOnwardBoardingInfo = string.Empty;
                if (BookingDetails[19].ToString().Trim() == "TICKETGOOSE")
                {
                    strOnwardBoardingInfo = Convert.ToString(BookingDetails[4].Split('~')[0]);
                }
                else
                {
                    strOnwardBoardingInfo = Convert.ToString(BookingDetails[4]);
                }

                // string strOnwardBoardingInfo = dtOnwardBoardingInfo.Rows[0]["address"].ToString() + "," +
                // dtOnwardBoardingInfo.Rows[0]["landmark"].ToString();

                String referenceNumber = "";
                String referenceNumberReturn = "";
                referenceNumber = GenerateManabusRefNo();
                string provider = BookingDetails[19].ToString();

                if (BookingDetails[5].ToLower().Contains("single"))
                {
                    Session["Ticketrefno"] = referenceNumber;
                }

                Session["Order_Id"] = referenceNumber;
                Session["Amount"] = lblTotalAmountPayable.Text;
                string phoneno;
                //SingleTrip
                if (BookingDetails[5].ToLower().Contains("single"))
                {

                    #region onwardTrip
                    String nameList = ""; String genderList = ""; String titleList = ""; String ageList = "";
                    int countlist = 0;
                    foreach (RepeaterItem item in rptPassengersonward.Items)
                    {
                        DropDownList ddlrptr = (DropDownList)item.FindControl("ddlGender");
                        TextBox txtPassengerNamerptr = (TextBox)item.FindControl("txtPassengerName");
                        TextBox txtAgerptr = (TextBox)item.FindControl("txtAge");
                        phoneno = txtPhoneNo.Text;
                        if (countlist == 0)
                        {
                            ++countlist;
                            nameList += txtPassengerNamerptr.Text;
                            titleList += ddlrptr.SelectedItem.Value.ToString();
                            ageList += txtAgerptr.Text;
                            genderList += ddlrptr.SelectedItem.Text.ToString();
                        }
                        else
                        {
                            ++countlist;
                            nameList += "," + txtPassengerNamerptr.Text;
                            titleList += "," + ddlrptr.SelectedItem.Value.ToString();
                            ageList += "," + txtAgerptr.Text;
                            genderList += "," + ddlrptr.SelectedItem.Text.ToString();
                        }
                    }

                    String passengerDetailsonward = "";
                    string bookingid = "";
                    string boarding = lblBoardingPoint.ToolTip.ToString();
                    BlockSeats blockseats = new BlockSeats();
                    blockseats.SourceId = int.Parse(BookingDetails[10]);
                    blockseats.DestinationId = int.Parse(BookingDetails[11]);
                    blockseats.TripId = BookingDetails[12];
                    blockseats.JourneyDate = BookingDetails[1];
                    blockseats.BoardingId = BookingDetails[4].Split('~')[1];
                    blockseats.NoOfSeats = countlist;
                    blockseats.SeatNo = BookingDetails[2];
                    blockseats.Title = titleList;
                    blockseats.Name = nameList;
                    blockseats.Age = ageList;
                    blockseats.Sex = genderList;
                    blockseats.Address = txtAddress.Text;
                    blockseats.BookingRefNo = referenceNumber;
                    blockseats.IdCardType = ddlIDType.SelectedItem.Text;
                    blockseats.IdCardNo = txtIDNumber.Text;
                    blockseats.IdCardIssuedBy = txtIdIssuedBY.Text;
                    blockseats.MobileNo = txtPhoneNo.Text;
                    blockseats.EmergencyMobileNo = txtPhoneNo.Text;
                    blockseats.EmailId = txtEmailId.Text;
                    blockseats.ProviderName = BookingDetails[19].ToString();
                    blockseats.BookingId = bookingid;
                    string blockresult = client.blockTicket(blockseats);
                    DataSet ds = convertJsonStringToDataSet(blockresult);
                    if (ds != null)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Columns.Contains("Status"))
                            {
                                if (ds.Tables[0].Rows[0]["Status"].ToString().ToUpper() == "SUCCESS")
                                {
                                    if (ds.Tables[0].Columns.Contains("BookingID"))
                                    {
                                        blockseats.BookingId = ds.Tables[0].Rows[0]["BookingID"].ToString();
                                        lblMsg.Text = Convert.ToString(ds.Tables[0].Rows[0]["Status"]);
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = ds.Tables[0].Rows[0]["message"].ToString();
                                    return;
                                }
                            }
                        }
                    }
                    if (Session["UserID"] != null)
                    {
                        if (Session["Role"].ToString() == "Agent")
                        {
                            ClsBAL objBAL = new ClsBAL();
                            DataSet dsBalance = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"]));
                            DataSet dsCommSlab = objBAL.GetCommissionSlab(Session["Role"].ToString(), "Bus", provider); // Change it
                            if (dsCommSlab != null)
                            {
                                if (dsCommSlab.Tables[0].Rows.Count > 0)
                                {
                                    string commisionPercentage = dsCommSlab.Tables[0].Rows[0]["Commission"].ToString();// Change it

                                    string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                                    //string commisionPercentage = dsBalance.Tables[0].Rows[0]["CommisionPercentage"].ToString();
                                    string agentId = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();
                                    string actualFare;
                                    string deductAmount;
                                    string commisionFare;
                                    if (ViewState["MarkUp"] != null)
                                    {
                                        double Am = Convert.ToDouble(lblTotalAmountPayable.Text.ToString()) - Convert.ToDouble(ViewState["MarkUp"].ToString());
                                        actualFare = Am.ToString();
                                        deductAmount = Convert.ToString(Convert.ToDouble(actualFare.ToString()) - ((Convert.ToDouble(actualFare.ToString()) * Convert.ToDouble(commisionPercentage)) / 100));
                                        commisionFare = Convert.ToString(Convert.ToDouble(actualFare.ToString()) - Convert.ToDouble(deductAmount));

                                    }
                                    else
                                    {
                                         actualFare = lblTotalAmountPayable.Text.ToString();
                                         deductAmount = Convert.ToString(Convert.ToDouble(lblTotalAmountPayable.Text.ToString()) - ((Convert.ToDouble(lblTotalAmountPayable.Text.ToString()) * Convert.ToDouble(commisionPercentage)) / 100));
                                         commisionFare = Convert.ToString(Convert.ToDouble(lblTotalAmountPayable.Text.ToString()) - Convert.ToDouble(deductAmount));
                                    }

                                    Session["AgentId_Agent"] = agentId;
                                    Session["ActualFare_Agent"] = actualFare;
                                    Session["CommisionFare_Agent"] = commisionFare;
                                    Session["CommisionPercentage_Agent"] = commisionPercentage;
                                    Session["DeductAmount_Agent"] = deductAmount;
                                    Session["Markup"] = ViewState["MarkUp"];
                                    if (Convert.ToDouble(balance) >= Convert.ToDouble(deductAmount))
                                    {
                                        bool b = objBAL.UpdateAgentBalance(Convert.ToInt32(agentId), Convert.ToDouble(deductAmount), Convert.ToDouble(commisionFare));
                                        //UpdateagentBalance,@RefundAmount

                                    }
                                    else
                                    {
                                        lblMsg.Text = "You dont have enough balance to book a ticket.";
                                        return;
                                    }
                                }
                                else
                                {
                                    lblMsg.Text = "Please Contact administrater ";
                                    return;
                                }
                            }
                        }
                    }

                    Session["blockseats"] = blockseats;

                    if (lblMsg.Text.ToString().ToUpper() == "SUCCESS" && lblMsg.Text.ToString().ToLower() != "tentative booking failed")
                    {
                        string[] strDate = BookingDetails[1].Trim().ToString().Split('-');
                        dt = Convert.ToDateTime(strDate[2] + "-" + strDate[1] + "-" + strDate[0]);
                        int countpassengers = 0;
                        foreach (RepeaterItem item in rptPassengersonward.Items)
                        {
                            DropDownList ddlrptr = (DropDownList)item.FindControl("ddlGender");
                            Label lblSeatNorptr = (Label)item.FindControl("lblSeatNo");
                            TextBox txtPassengerNamerptr = (TextBox)item.FindControl("txtPassengerName");
                            TextBox txtAgerptr = (TextBox)item.FindControl("txtAge");
                            if (countpassengers == 0)
                            {
                                ++countpassengers;
                                passengerDetailsonward += lblSeatNorptr.Text + "-" + ddlrptr.SelectedItem.Value + "-" + txtPassengerNamerptr.Text + "-" + txtAgerptr.Text;
                            }
                            else
                            {
                                ++countpassengers;
                                passengerDetailsonward += "," + lblSeatNorptr.Text + "-" + ddlrptr.SelectedItem.Value + "-" + txtPassengerNamerptr.Text + "-" + txtAgerptr.Text;
                            }
                        }
                    }
                    string[] str = new string[1];
                    str[0] = " to";
                    //BookingDetails[4].Split('-')[7].Split('~')[1]
                    String[] cities = BookingDetails[0].ToString().Split(str, StringSplitOptions.None);
                    res = InsertTentativeBooking(referenceNumber, Convert.ToString(Session["Ticketrefno"]), blockseats.BookingId, lblMsg.Text.ToString(), "", "", null, provider
                            , BookingDetails[15].ToString(), BookingDetails[14].ToString(), dt
                            , Convert.ToInt32(BookingDetails[10].ToString()), cities[0].ToString()
                            , Convert.ToInt32(BookingDetails[11].ToString()), cities[1].ToString()
                        , lblSeatNos.Text.ToString(), rptPassengersonward.Items.Count,Convert.ToDecimal(ViewState["MarkUp"].ToString()),  Convert.ToDecimal(lblFare.Text.Trim().ToString()), null
                            , strOnwardBoardingInfo, BookingDetails[4].Split('-')[0].ToString() + "-" + BookingDetails[4].Split('-')[BookingDetails[4].Split('-').Length - 1].ToString().Split('~')[0].ToString(), nameList, 20, "M", txtPhoneNo.Text.ToString()
                            , txtEmailId.Text.ToString(), txtAddress.Text.ToString()
                            , "", null, 0, 0, "Online", "Cash", "Oneway", createdBy, "Online", "", passengerDetailsonward
                            , ddlIDType.SelectedItem.Text.ToString(), txtIDNumber.Text.ToString(), "", provider, Convert.ToDouble(Session["CommisionFare_Agent"]), blockseats.TripId, blockseats.Title, Convert.ToString(blockseats.BoardingId));
                    if (res == true)
                    {
                        if (Session["UserID"] != null)
                        {
                            if (Session["Role"].ToString() == "Admin" || Session["Role"].ToString() == "CSE")
                            {

                                lblMsg.Text = client.bookTicket(blockseats);
                                DataSet dsbook = convertJsonStringToDataSet(lblMsg.Text);
                                if (dsbook != null)
                                {
                                    if (dsbook.Tables[0].Rows.Count > 0)
                                    {
                                        if (dsbook.Tables[0].Columns.Contains("APIPNR"))
                                        {
                                            lblMsg.Text = dsbook.Tables[0].Rows[0]["APIPNR"].ToString();
                                        }
                                    }
                                }
                                if (Convert.ToString(dsbook.Tables[0].Rows[0]["APIPNR"]) == "SUCCESS" || Convert.ToString(dsbook.Tables[0].Rows[0]["Status"]).ToUpper() == "SUCCESS")
                                {
                                    if (lblMsg.Text.ToString().Split(' ').Length == 1)
                                    {
                                        InsertBookedTicketDetails(referenceNumber, lblMsg.Text.ToString());
                                        Response.Redirect("redirectbus.aspx", false);

                                    }
                                }
                                else
                                {
                                    return; //Booking Failed.
                                }
                            }
                            else if (Session["Role"].ToString() == "Agent")
                            {

                                lblMsg.Text = client.bookTicket(blockseats);
                                DataSet dsbook = convertJsonStringToDataSet(lblMsg.Text);
                                if (dsbook != null)
                                {
                                    if (dsbook.Tables[0].Rows.Count > 0)
                                    {
                                        if (dsbook.Tables[0].Columns.Contains("APIPNR"))
                                        {
                                            lblMsg.Text = dsbook.Tables[0].Rows[0]["APIPNR"].ToString();
                                        }
                                    }
                                }
                                if (Convert.ToString(dsbook.Tables[0].Rows[0]["APIPNR"]) == "SUCCESS" || Convert.ToString(dsbook.Tables[0].Rows[0]["Status"]).ToUpper() == "SUCCESS")
                                {
                                    if (lblMsg.Text.ToString().Split(' ').Length == 1)
                                    {
                                        InsertBookedTicketDetails(referenceNumber, lblMsg.Text.ToString());
                                        Response.Redirect("redirectbus.aspx", false);

                                    }
                                }
                                else
                                {
                                    return; //Booking Failed.
                                }

                            }
                            else if (Convert.ToDouble(lblTotalAmountPayable.Text) == Convert.ToDouble(0))
                            {
                                lblMsg.Text = client.bookTicket(blockseats);
                                DataSet dsbook = convertJsonStringToDataSet(lblMsg.Text);
                                if (dsbook != null)
                                {
                                    if (dsbook.Tables[0].Rows.Count > 0)
                                    {
                                        if (dsbook.Tables[0].Columns.Contains("APIPNR"))
                                        {
                                            lblMsg.Text = dsbook.Tables[0].Rows[0]["APIPNR"].ToString();
                                        }
                                    }
                                }
                                if (Convert.ToString(dsbook.Tables[0].Rows[0]["APIPNR"]) == "SUCCESS" || Convert.ToString(dsbook.Tables[0].Rows[0]["Status"]).ToUpper() == "SUCCESS")
                                {
                                    if (lblMsg.Text.ToString().Split(' ').Length == 1)
                                    {
                                        InsertBookedTicketDetails(referenceNumber, lblMsg.Text.ToString());
                                        Response.Redirect("redirectbus.aspx", false);

                                    }
                                }
                                else
                                {
                                    return; //Booking Failed.
                                }
                            }
                            else if (Session["Role"].ToString() == "User")
                            {
                                Server.Transfer("Pay.aspx?val=bus");
                            }
                        }
                        else
                        {
                            // Response.Redirect("redirectbus.aspx?Refno=" + Session["Ticketrefno"].ToString(), false);
                            Response.Redirect("Pay.aspx?val=bus", false);
                        }
                    }

                    #endregion

                }

            }
            else
            {
                Response.Redirect("~/Default.aspx", false);
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.ToString();
        }
    }
        private void saveround(object sender, EventArgs e)
        {
        try
        {
            DataSet ds = new DataSet();
            FlightBAL objFlightsBal = new FlightBAL();
            string ReferenceNo = Convert.ToString(Session["Order_Id"]);
            DataSet dtid = objFlightsBal.IGetInternationalFlightDetails(ReferenceNo);

            id1 = dtid.Tables[0].Rows[0]["id"].ToString();
            key = dtid.Tables[0].Rows[0]["Key1"].ToString();
            string[] strfare = dtid.Tables[0].Rows[0]["ActualBasefare"].ToString().Split('.');
            actualBaseFare = strfare[0].ToString();
            string[] strtax = dtid.Tables[0].Rows[0]["Tax"].ToString().Split('.');
            tax = strtax[0].ToString();
            string[] strstax = dtid.Tables[0].Rows[0]["STax"].ToString().Split('.');
            Stax = strstax[0].ToString();
            string[] strscharge = dtid.Tables[0].Rows[0]["Scharge"].ToString().Split('.');
            SCharge = strscharge[0].ToString();
            string[] strtdis = dtid.Tables[0].Rows[0]["TDiscount"].ToString().Split('.');
            TDiscount = strtdis[0].ToString();
            string[] strtcomm = dtid.Tables[0].Rows[0]["TPartnerCommission"].ToString().Split('.');
            TPartnerCommission = strtcomm[0].ToString();
            string[] strtsdis = dtid.Tables[0].Rows[0]["TSDiscount"].ToString().Split('.');
            TSdiscount = strtsdis[0].ToString();

            string[] strmark = dtid.Tables[0].Rows[0]["TMarkUp"].ToString().Split('.');
            TMarkup = strmark[0].ToString();
            string[] strtcharge = dtid.Tables[0].Rows[0]["TCharge"].ToString().Split('.');
            TCharge = strtcharge[0].ToString();

            idRet = dtid.Tables[0].Rows[0]["idRet"].ToString();
            keyRet = dtid.Tables[0].Rows[0]["Key1Ret"].ToString();
            string[] strfareRet = dtid.Tables[0].Rows[0]["ActualBasefareRet"].ToString().Split('.');
            actualBaseFareRet = strfareRet[0].ToString();
            string[] strtaxRet = dtid.Tables[0].Rows[0]["TaxRet"].ToString().Split('.');
            taxRet = strtaxRet[0].ToString();
            string[] strstaxRet = dtid.Tables[0].Rows[0]["STaxRet"].ToString().Split('.');
            StaxRet = strstaxRet[0].ToString();
            string[] strschargeRet = dtid.Tables[0].Rows[0]["SchargeRet"].ToString().Split('.');
            SChargeRet = strschargeRet[0].ToString();
            string[] strtdisRet = dtid.Tables[0].Rows[0]["TDiscountRet"].ToString().Split('.');
            TDiscountRet = strtdisRet[0].ToString();
            string[] strtcommRet = dtid.Tables[0].Rows[0]["TPartnerCommissionRet"].ToString().Split('.');
            TPartnerCommissionRet = strtcommRet[0].ToString();
            string[] strtsdisRet = dtid.Tables[0].Rows[0]["TSDiscountRet"].ToString().Split('.');
            TSdiscountRet = strtsdisRet[0].ToString();

            string[] strmarkRet = dtid.Tables[0].Rows[0]["TMarkUpRet"].ToString().Split('.');
            TMarkupRet = strmarkRet[0].ToString();
            string[] strtchargeRet = dtid.Tables[0].Rows[0]["TChargeRet"].ToString().Split('.');
            TChargeRet = strtchargeRet[0].ToString();

            //   octax = dtid.Tables[0].Rows[0]["Octax"].ToString();
            Customer_Details = dtid.Tables[0].Rows[0]["Customer_Details"].ToString();
            telephone = dtid.Tables[0].Rows[0]["telephone"].ToString();
            emailAddress = dtid.Tables[0].Rows[0]["emailAddress"].ToString();

            adultcnt = Convert.ToInt32(dtid.Tables[0].Rows[0]["AdultPax"]);
            infantCnt = Convert.ToInt32(dtid.Tables[0].Rows[0]["InfantPax"]);
            childCnt = Convert.ToInt32(dtid.Tables[0].Rows[0]["ChildPax"]);
            refNo = dtid.Tables[0].Rows[0]["ReferenceNo"].ToString();

            string ReferenceNo1 = dtid.Tables[0].Rows[0]["Dom_Booking_Id"].ToString();
            DataSet dsdbsave = objFlightsBal.GetInternationalFlightDetailsI1(ReferenceNo1);
            //1st row

            AirEquipType = dsdbsave.Tables[0].Rows[0]["AirEquipType"].ToString();
            ArrivalAirportCode = dsdbsave.Tables[0].Rows[0]["ArrivalAirportCode"].ToString();
            // ArrivalAirportName = dsdbsave.Tables[0].Rows[0]["ArrivalAirportName"].ToString();
            ArrivalDateTime = dsdbsave.Tables[0].Rows[0]["ArrivalDateTime"].ToString();
            DepartureAirportCode = dsdbsave.Tables[0].Rows[0]["DepartureAirportCode"].ToString();
            //  DepartureAirportName = dsdbsave.Tables[0].Rows[0]["DepartureAirportName"].ToString();
            DepartureDateTime = dsdbsave.Tables[0].Rows[0]["DepartureDateTime"].ToString();
            FlightNumber = dsdbsave.Tables[0].Rows[0]["FlightNumber"].ToString();
            // MarketingAirlineCode = dsdbsave.Tables[0].Rows[0]["MarketingAirlineCode"].ToString();
            OperatingAirlineCode = dsdbsave.Tables[0].Rows[0]["OperatingAirlineCode"].ToString();
            airLineName = dsdbsave.Tables[0].Rows[0]["airlineName"].ToString();
            OperatingAirlineFlightNumber = dsdbsave.Tables[0].Rows[0]["OperatingAirlineFlightNumber"].ToString();
            RPH = dsdbsave.Tables[0].Rows[0]["RPH"].ToString();
            StopQuantity = dsdbsave.Tables[0].Rows[0]["StopQuantity"].ToString();
            airportTax = dsdbsave.Tables[0].Rows[0]["airportTax"].ToString();
            imageFileName = dsdbsave.Tables[0].Rows[0]["imageFileName"].ToString();
            string[] strdis = dsdbsave.Tables[0].Rows[0]["Discount"].ToString().Split('.');
            Discount = strdis[0].ToString();
            airportTaxChild = dsdbsave.Tables[0].Rows[0]["airportTaxChild"].ToString();
            airportTaxInfant = dsdbsave.Tables[0].Rows[0]["airportTaxInfant"].ToString();
            airportTaxChild = dsdbsave.Tables[0].Rows[0]["airportTaxChild"].ToString();
            airportTaxInfant = dsdbsave.Tables[0].Rows[0]["airportTaxInfant"].ToString();
            childTaxBreakup = dsdbsave.Tables[0].Rows[0]["ChildTaxBreakUp"].ToString();
            infantTaxBreakup = dsdbsave.Tables[0].Rows[0]["InfantTaxBreakUp"].ToString();
            adultTaxBreakup = dsdbsave.Tables[0].Rows[0]["adultTaxBreakUp"].ToString();
            octax = dsdbsave.Tables[0].Rows[0]["ocTax"].ToString();
            BookingClassResBookDesigCode = dsdbsave.Tables[0].Rows[0]["ResBookingCode"].ToString();
            string[] stradultfare = dsdbsave.Tables[0].Rows[0]["adultFare"].ToString().Split('.');
            adultFare = stradultfare[0].ToString();

            BookingClassAvailability = dsdbsave.Tables[0].Rows[0]["Availability"].ToString();
            string[] strchildfare = dsdbsave.Tables[0].Rows[0]["ChildFare"].ToString().Split('.');
            childFare = strchildfare[0].ToString();
            bookingclass = dsdbsave.Tables[0].Rows[0]["bookingClass"].ToString();
            classType = dsdbsave.Tables[0].Rows[0]["ClassType"].ToString();
            farebasiscode = dsdbsave.Tables[0].Rows[0]["farebasisCode"].ToString();
            string[] strinffare = dsdbsave.Tables[0].Rows[0]["infantFare"].ToString().Split('.');
            infantfare = strinffare[0].ToString();

            Rule = dsdbsave.Tables[0].Rows[0]["Fare_Rule"].ToString();
            string[] stradultcomm = dsdbsave.Tables[0].Rows[0]["adultCommission"].ToString().Split('.');
            adultCommission = stradultcomm[0].ToString();
            string[] strchildcomm = dsdbsave.Tables[0].Rows[0]["childCommission"].ToString().Split('.');
            childCommission = strchildcomm[0].ToString();
            string[] strcommoncharge = dsdbsave.Tables[0].Rows[0]["CommissionOnTCharge"].ToString().Split('.');
            commissionOnTCharge = strcommoncharge[0].ToString();

            //2nd row

            AirEquipTypeRet = dsdbsave.Tables[0].Rows[1]["AirEquipType"].ToString();
            ArrivalAirportCodeRet = dsdbsave.Tables[0].Rows[1]["ArrivalAirportCode"].ToString();
            // ArrivalAirportName = dsdbsave.Tables[0].Rows[0]["ArrivalAirportName"].ToString();
            ArrivalDateTimeRet = dsdbsave.Tables[0].Rows[1]["ArrivalDateTime"].ToString();
            DepartureAirportCodeRet = dsdbsave.Tables[0].Rows[1]["DepartureAirportCode"].ToString();
            //  DepartureAirportName = dsdbsave.Tables[0].Rows[0]["DepartureAirportName"].ToString();
            DepartureDateTimeRet = dsdbsave.Tables[0].Rows[1]["DepartureDateTime"].ToString();
            FlightNumberRet = dsdbsave.Tables[0].Rows[1]["FlightNumber"].ToString();
            // MarketingAirlineCode = dsdbsave.Tables[0].Rows[0]["MarketingAirlineCode"].ToString();
            OperatingAirlineCodeRet = dsdbsave.Tables[0].Rows[1]["OperatingAirlineCode"].ToString();
            airLineNameRet = dsdbsave.Tables[0].Rows[1]["airlineName"].ToString();
            OperatingAirlineFlightNumberRet = dsdbsave.Tables[0].Rows[1]["OperatingAirlineFlightNumber"].ToString();
            RPHRet = dsdbsave.Tables[0].Rows[1]["RPH"].ToString();
            StopQuantityRet = dsdbsave.Tables[0].Rows[1]["StopQuantity"].ToString();
            airportTaxRet = dsdbsave.Tables[0].Rows[1]["airportTax"].ToString();
            imageFileNameRet = dsdbsave.Tables[0].Rows[1]["imageFileName"].ToString();
            string[] strdisRet = dsdbsave.Tables[0].Rows[1]["Discount"].ToString().Split('.');
            DiscountRet = strdisRet[0].ToString();
            airportTaxChildRet = dsdbsave.Tables[0].Rows[1]["airportTaxChild"].ToString();
            airportTaxInfantRet = dsdbsave.Tables[0].Rows[1]["airportTaxInfant"].ToString();
            airportTaxChildRet = dsdbsave.Tables[0].Rows[1]["airportTaxChild"].ToString();
            airportTaxInfantRet = dsdbsave.Tables[0].Rows[1]["airportTaxInfant"].ToString();
            childTaxBreakupRet = dsdbsave.Tables[0].Rows[1]["ChildTaxBreakUp"].ToString();
            infantTaxBreakupRet = dsdbsave.Tables[0].Rows[1]["InfantTaxBreakUp"].ToString();
            adultTaxBreakupRet = dsdbsave.Tables[0].Rows[0]["adultTaxBreakUp"].ToString();
            octaxRet = dsdbsave.Tables[0].Rows[1]["ocTax"].ToString();
            BookingClassResBookDesigCodeRet = dsdbsave.Tables[0].Rows[1]["ResBookingCode"].ToString();
            string[] stradultretfare = dsdbsave.Tables[0].Rows[1]["adultFare"].ToString().Split('.');
            adultFareRet = stradultretfare[0].ToString();

            BookingClassAvailabilityRet = dsdbsave.Tables[0].Rows[1]["Availability"].ToString();
            string[] strchildretfare = dsdbsave.Tables[0].Rows[1]["ChildFare"].ToString().Split('.');
            childFareRet = strchildretfare[0].ToString();
            bookingclassRet = dsdbsave.Tables[0].Rows[1]["bookingClass"].ToString();
            classTypeRet = dsdbsave.Tables[0].Rows[1]["ClassType"].ToString();
            farebasiscodeRet = dsdbsave.Tables[0].Rows[1]["farebasisCode"].ToString();
            string[] strinfantfareret = dsdbsave.Tables[0].Rows[1]["infantFare"].ToString().Split('.');
            infantfareRet = strinfantfareret[0].ToString();

            RuleRet = dsdbsave.Tables[0].Rows[1]["Fare_Rule"].ToString();
            string[] stracr = dsdbsave.Tables[0].Rows[1]["adultCommission"].ToString().Split('.');
            adultCommissionRet = stracr[0].ToString();
            string[] strccr = dsdbsave.Tables[0].Rows[1]["childCommission"].ToString().Split('.');
            childCommissionRet = strccr[0].ToString();
            string[] ctcr = dsdbsave.Tables[0].Rows[1]["CommissionOnTCharge"].ToString().Split('.');
            commissionOnTChargeRet = ctcr[0].ToString();

            //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><returnFlights/> <telePhone>" + txtPhoneNum.Text + "</telePhone><email>" + txtEmailID.Text + "</email> <creditcardno></creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + adultcnt + "</AdultPax><ChildPax>" + childCnt + "</ChildPax><InfantPax>" + infantCnt + "</InfantPax></pricingrequest>";
            //DataSet dsFlightPricing = objFlights.GetPricingDetails(XMLPricing);
            #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>" + id1 + "</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>" + telephone + "</telePhone><email>" + emailAddress + "</email> <creditcardno></creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + adultcnt + "</AdultPax><ChildPax>" + childCnt + "</ChildPax><InfantPax>" + infantCnt + "</InfantPax></pricingrequest>";

            DataSet dsFlightPricing = objFlights.GetPricingDetails(XMLPricing);
            if (dsFlightPricing.Tables.Count > 0)
            {

                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];
                    DataTable dtNonchangeprice = dsFlightPricing.Tables[5];
                    if (dtchangeprice.Rows.Count > 0)
                    {
                        DataRow[] rowchangeprices = dtchangeprice.Select("FareDetails_Id=" + fareDetailsIdRet);
                        DataRow[] rowNonchangeprices = dtNonchangeprice.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();
                        TChargeRet = rowNonchangeprices[0]["TCharge"].ToString();
                        TotalFare = (Convert.ToDecimal(actualBaseFareRet) + Convert.ToDecimal(taxRet) + Convert.ToDecimal(StaxRet) + Convert.ToDecimal(TChargeRet) + Convert.ToDecimal(rowNonchangeprices[0]["TMarkup"])).ToString();//+ Convert.ToDecimal(SChargeRet) + Convert.ToDecimal(TDiscountRet)
                    }
                }
            }

            #endregion

            refNo = Convert.ToString(Session["Order_Id"]);

            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>" + id1 + "</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
            #region old

            //Table tbladults = (Table)this.UpdatePanel1.FindControl("tblAdults");
            //for (int i = 1; i <= 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 <= 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 <= 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>";
            //}
            #endregion
            string strname = dtid.Tables[0].Rows[0]["Customer_Details"].ToString();
            string[] strrows = strname.ToString().Split(';');
            int id = strrows.Count();
            for (int m = 0; m < id; m++)
            {
                if (strrows[m].ToUpper().Contains("ADT"))
                {
                    string[] stradt = strrows[m].ToString().Split('|');
                    xmlRequestData = xmlRequestData + "<CustomerInfo><givenName>" + stradt[1].ToString() + "</givenName><surName>" + stradt[2].ToString() + "</surName><nameReference>" + stradt[0].ToString() + "</nameReference><psgrtype>adt</psgrtype></CustomerInfo>";
                }
                if (strrows[m].ToUpper().Contains("CHD"))
                {
                    string[] strchd = strrows[m].ToString().Split('|');
                    xmlRequestData = xmlRequestData + "<CustomerInfo><givenName>" + strchd[1].ToString() + "</givenName><surName>" + strchd[2].ToString() + "</surName><nameReference>" + strchd[0].ToString() + "</nameReference><dob>" + strchd[5].ToString() + "</dob><age>" + strchd[4].ToString() + "</age><psgrtype>chd</psgrtype></CustomerInfo>";
                }
                if (strrows[m].ToUpper().Contains("INF"))
                {
                    string[] strinf = strrows[m].ToString().Split('|');
                    xmlRequestData = xmlRequestData + "<CustomerInfo><givenName>" + strinf[1].ToString() + "</givenName><surName>" + strinf[2].ToString() + "</surName><nameReference>" + strinf[0].ToString() + "</nameReference><dob>" + strinf[5].ToString() + "</dob><age>" + strinf[4].ToString() + "</age><psgrtype>inf</psgrtype></CustomerInfo>";

                }
            }

            xmlRequestData = xmlRequestData + "</personName><telePhone><phoneNumber>" + telephone + "</phoneNumber></telePhone><email><emailAddress>" + emailAddress + "</emailAddress></email><creditcardno>4111111111111111</creditcardno><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword> <partnerRefId>" + refNo + "</partnerRefId> <Clienttype>ArzooFWS1.1</Clienttype><AdultPax>" + Session["adultcnt"].ToString() + "</AdultPax><ChildPax>" + Session["childCnt"].ToString() + "</ChildPax><InfantPax>" + Session["infantCnt"].ToString() + "</InfantPax></Bookingrequest>";
            DataSet dsBookingResponse = new DataSet();

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

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

            //string actualFare = lblTotalOnwardReturn.Text;
            //string deductAmount = Convert.ToString(Convert.ToDouble(actualFare.ToString()) -
            //    ((Convert.ToDouble(actualFare.ToString()) * Convert.ToInt32(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);
            //}
            //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();

                //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(Session["CommisionPercentage_Agent"].ToString()));

                //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
                #region Dedcuting the amount from the agent and DB's balance after booking

                if (Session["UserID"] != null)
                {
                    if (Session["Role"] != null)
                    {
                        if (Session["Role"].ToString() == "Agent" || Session["Role"].ToString() == "Distributor")
                        {
                            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 = balanceAgent;
                            Session["Balance"] = balanceAgent;
                        }
                        else if (Session["Role"].ToString() == "User")
                        {
                            DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), refNo, Convert.ToDouble(Session["Amount"].ToString()),
                                                Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                        }
                        else if (Session["Role"].ToString() == "Admin")
                        {
                            DeductAgentBalance(0, Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), refNo, Convert.ToDouble(Session["Amount"].ToString()),
                                               Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                        }
                    }
                }
                else if (Session["Role"] == null)
                {
                    DeductAgentBalance(0, Convert.ToDouble("0.00"), 0, refNo, Convert.ToDouble(Session["Amount"].ToString()),
                                              Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                }
                #endregion
                FlightBAL objFlightBal = new FlightBAL();

                objFlightBal.ReferenceNo = refNo;
                objFlightBal.TransId = transId;
                objFlightBal.Status = dsBookingResponse.Tables["Bookingresponse"].Rows[0]["status"].ToString();
                if (objFlightBal.Status == "SUCCESS")
                {
                    objFlightsBal.UpdateDomesticFlightBooking(objFlightBal);
                    GetBookingStatus(objFlightBal.ReferenceNo);
                }
                else
                {
                    objFlightsBal.UpdateDomesticFlightBooking(objFlightBal);
                }

                GetDetailsForPrint(Convert.ToString(Session["Order_Id"]));
                lbtnmail.Visible = false;
                pnlSearch.Visible = false;
                lbtnmail_Click1(sender, e);
                pnlPassengerDet.Visible = false;
                lblStatus.Visible = true;
                lblStatus.Text = "Ticket has been booked successfully. Reference Number is : " + Convert.ToString(Session["Order_Id"]);
                lblStatus.ForeColor = System.Drawing.Color.Green;
                //  Response.Redirect("Pay.aspx", false);

            }
            else
            {
                lblStatus.Text = dsBookingResponse.Tables[0].Rows[0]["Error"].ToString();
                lblStatus.Visible = true;
            }
        }
        catch (Exception ex)
        {
        }
    }
    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;
        }
    }
Ejemplo n.º 18
0
    protected void btnDepositSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            objBal = new ClsBAL();

            ListItem value = ddlAgents.Items.FindByText(txtAgents.Text.ToString());

            if (value == null)
            {
                ddlAgents.SelectedIndex = 0;
                lblMsg.InnerHtml = "The Agent Username does not exists.";

                txtAgentName.Focus();
                txtAgentName.Text = "";
            }
            else
            {
                if (Session["Role"].ToString() == "Admin")
                {
                    ddlAgents.SelectedItem.Value = value.Value;
                    string msg = objBal.AddAgentDeposit(Convert.ToInt32(ddlAgents.SelectedItem.Value.ToString())
                        , Convert.ToDouble(txtAmount.Text.ToString()), txtDepositDetails.Text.Trim().ToString(), Convert.ToInt32(Session["UserID"].ToString())
                        , rbtnType.SelectedItem.Text.ToString(), txtTransactionNo.Text.Trim().ToString(), txtReason.Text.Trim());

                    BindDeposits();
                    DeductAgentBalance(Convert.ToInt32(ddlAgents.SelectedItem.Value), Convert.ToDouble(0.00),
                                Convert.ToInt32(Userid), rbtnType.SelectedItem.Text.ToString(), Convert.ToDouble(txtAmount.Text.ToString()),
                                Convert.ToDouble(0.00), Convert.ToInt32(0.00));

                    System.Data.DataSet ds = objBal.GetAgentById(Convert.ToInt32(ddlAgents.SelectedItem.Value.ToString()));

                    string body = "Dear " + ds.Tables[0].Rows[0]["UserName"].ToString() + ", <br/> " + "Rs. " + txtAmount.Text.ToString() + "/- amount has been credited in your account. <br/><br/> Thanks, <br/>Love Journey Team";
                    bool res = Mailsender.SendEmail(ds.Tables[0].Rows[0]["EmailId"].ToString(), "", "", "Deposit Details", body);

                    lblMsg.InnerHtml = msg;
                    BindDeposits(); txtAmount.Text = txtDepositDetails.Text = txtTransactionNo.Text = txtReason.Text = ""; rbtnType.SelectedIndex = -1;
                }
                else if (Session["Role"].ToString() == "Distributor")
                {
                    if (Convert.ToDouble(Session["Balance"].ToString()) >= Convert.ToDouble(txtAmount.Text.ToString()))
                    {
                        ddlAgents.SelectedItem.Value = value.Value;
                        string msg = objBal.AddAgentDeposit(Convert.ToInt32(ddlAgents.SelectedItem.Value.ToString())
                            , Convert.ToDouble(txtAmount.Text.ToString()), txtDepositDetails.Text.Trim().ToString(), Convert.ToInt32(Session["UserID"].ToString())
                            , rbtnType.SelectedItem.Text.ToString(), txtTransactionNo.Text.Trim().ToString(), txtReason.Text.Trim());

                        BindDeposits();
                        DeductAgentBalance(Convert.ToInt32(ddlAgents.SelectedItem.Value), Convert.ToDouble(0.00),
                                    Convert.ToInt32(Userid), rbtnType.SelectedItem.Text.ToString(), Convert.ToDouble(txtAmount.Text.ToString()),
                                    Convert.ToDouble(0.00), Convert.ToInt32(0.00));

                        lblMsg.InnerHtml = msg;

                        if (msg == "Inserted Successfully.")
                        {
                            objBal.deductDistributorbalance(Convert.ToInt32(Session["UserID"].ToString()), Convert.ToDouble(txtAmount.Text.ToString()), "Deduct");

                            ClsBAL objBAL = new ClsBAL();
                            System.Data.DataSet dataset = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                            Session["Balance"] = dataset.Tables[0].Rows[0]["Balance"].ToString();

                            Label balance = (Label)this.Master.FindControl("lblDbBal");
                            balance.Text = "Your balance is : " + " " + Session["Balance"].ToString();

                        }

                        System.Data.DataSet ds = objBal.GetAgentById(Convert.ToInt32(ddlAgents.SelectedItem.Value.ToString()));

                        string body = "Dear " + ds.Tables[0].Rows[0]["UserName"].ToString() + ", <br/> " + "Rs. " + txtAmount.Text.ToString() + "/- amount has been credited in your account. <br/><br/> Thanks, <br/>Love Journey Team";
                        bool res = Mailsender.SendEmail(ds.Tables[0].Rows[0]["EmailId"].ToString(), "", "", "Deposit Details", body);

                        BindDeposits(); txtAmount.Text = txtDepositDetails.Text = txtTransactionNo.Text = txtReason.Text = ""; rbtnType.SelectedIndex = -1;
                    }
                    else
                    {
                        lblMsg.InnerHtml = "Your balance should be greater than the adding amount.";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblMsg.InnerHtml = ex.Message;

        }
    }
    protected void btnGet_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet dsGetTransId = new DataSet();
            dsGetTransId = objFlightBal.GetTransID(txtBookingReferenceNo.Text);
            transId = dsGetTransId.Tables[0].Rows[0]["transid"].ToString();

            if (transId != "")
            {

                String xmlCancelReqStatus = "<EticketCanStatusReq><Clientid>" + FlightsConstants.USERID + "</Clientid><Clientpassword>" + FlightsConstants.PASSWORD + "</Clientpassword><Clienttype>ArzooFWS1.0</Clienttype><transid>" + transId + "</transid><partnerRefId></partnerRefId><CancellationId></CancellationId></EticketCanStatusReq>";
                 DataSet dsCancelStatusResponse = objFlights.GetCancelTicketStatus(xmlCancelReqStatus);
                //DataSet dsCancelStatusResponse = new DataSet();
                //dsCancelStatusResponse.ReadXml("F:\\Projects\\Love Journey\\Cancel_Domestic_Static_Response.xml");
                if (dsCancelStatusResponse != null)
                {
                    objFlightBal.Status = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["CancellationStatus"].ToString();
                    objFlightBal.TransId = dsCancelStatusResponse.Tables["EticketCanStatusRes"].Rows[0]["transid"].ToString();
                    objFlightBal.ReferenceNo = txtBookingReferenceNo.Text;

                    objFlightBal.CancellationProcessDateTime = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["CancellationProcessDateTime"].ToString();
                    objFlightBal.CancellationCharges = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["CancellationCharges"].ToString();
                    objFlightBal.RefundStatus = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["RefundStatus"].ToString();
                    objFlightBal.FinalRefundAmount = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["FinalRefundAmount"].ToString();
                    objFlightBal.RefundDateTime = dsCancelStatusResponse.Tables["Cancellation"].Rows[0]["RefundDateTime"].ToString();

                    bool res = objFlightBal.UpdateDomesticFlightCancelStatus(objFlightBal);
                    ClsBAL objBAL = new ClsBAL();
                    objBAL.AdjustAgentBalance(txtBookingReferenceNo.Text.Trim().ToString(),
                        Convert.ToDouble(objFlightBal.FinalRefundAmount), Convert.ToDouble(objFlightBal.CancellationCharges),
                        Convert.ToInt32(Session["UserID"].ToString()));

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

                    string balance = dsBalance.Tables[0].Rows[0]["Balance"].ToString();
                    Label lbl = (Label)this.Master.FindControl("lblBalance");
                    lbl.Text = balance;
                    Session["Balance"] = balance;
                    if (res)
                    {
                        lblStatus.Text = "Updated the status";
                        lblStatus.ForeColor = System.Drawing.Color.Green;
                        lblStatus.Visible = true;
                    }
                }
            }
            else
            {
                lblStatus.Text = "Invalid Request";
            }
        }
        catch (Exception ex)
        {

        }
    }
Ejemplo n.º 20
0
 protected void lnkICICI_Click(object sender, EventArgs e)
 {
     ClsBAL objBAL = new ClsBAL();
     System.Data.DataSet ds = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
     Session["Name"] = ds.Tables[0].Rows[0]["AgentName"].ToString();
     Response.Redirect("~/Agent/Bus/ICICIBankPaySlip.aspx?Name=" + Session["Name"].ToString() + "&Code=" + Session["UserName"].ToString(), false);
 }
Ejemplo n.º 21
0
    protected void getbalance()
    {
        try
        {

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

            Session["AgentBalance"] = Convert.ToDecimal(dsBalance.Tables[0].Rows[0]["Balance"].ToString());
            Session["CommisionPercentage_Agent"] = dsBalance.Tables[0].Rows[0]["CommisionPercentage"].ToString();
            Session["AgentId_Agent"] = dsBalance.Tables[0].Rows[0]["AgentId"].ToString();
        }
        catch (Exception ex)
        {
        }
    }
Ejemplo n.º 22
0
    protected void lnksbi_Click(object sender, EventArgs e)
    {
        //Response.Redirect("~/Agent/Bus/SBIPaySlip.aspx?Name=" + Session["Name"].ToString() + "&Code=" + Session["UserName"].ToString(), false);
        //try
        //{

        //    //  GetDetailsForPrint(Refno);
        //    Response.Clear();
        //    Response.Buffer = true;
        //    Response.AddHeader("content-disposition", "attachment;filename=SBIpayinSlip.doc");
        //    Response.Charset = "";
        //    Response.ContentType = "application/vnd.ms-word";
        //    StringWriter sw = new StringWriter();
        //    HtmlTextWriter hw = new HtmlTextWriter(sw);
        //    pnlsbi.RenderControl(hw);
        //    Response.Output.Write(sw.ToString());
        //    Response.Flush();
        //    Response.End();

        //}
        //catch (System.Threading.ThreadAbortException lException)
        //{

        //    // do nothing

        //}

        ClsBAL objBAL = new ClsBAL();
        System.Data.DataSet ds = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
        Session["Name"] = ds.Tables[0].Rows[0]["AgentName"].ToString();
        Response.Redirect("~/Agent/Bus/SBIPaySlip.aspx?Name=" + Session["Name"].ToString() + "&Code=" + Session["UserName"].ToString(), false);
    }
    protected void Mail(string mailId, string refNo)
    {
        try
        {
            objBAL = new ClsBAL();
            System.Data.DataSet ds = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));

            if (mailId != "")
            {
                string body = "Your (" + refNo + ") ticket has been cancelled.";
                bool res = Mailsender.SendEmail(mailId, "", "", "Ticket Cancelled Details", body);
                if (res)
                {
                    lblMsg.Text = "Ticket Details has been sent to your mail.Please check.";
                    lblMsg.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void save(object sender, EventArgs e)
    {
        try
        {
            DataSet dsBookingResponse = new DataSet();

            // dsBookingResponse = (DataSet)Session["Response"];

            dsBookingResponse = method();
            Session["Response"] = null;
            FlightBAL objFlightBal = new FlightBAL();
            if (dsBookingResponse.Tables.Count > 0)
            {
                if (dsBookingResponse.Tables["BookingResponse"].Rows.Count > 0)
                {
                    if (Session["UserID"] != null && Session["Role"] != null)
                    {

                    #region Dedcuting the amount from the agent and DB's balance after booking

                        if (Session["Role"].ToString() == "Agent" || Session["Role"].ToString() == "Distributor")
                        {
                            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()), Session["Order_Id"].ToString(), 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 = balanceAgent;
                            Session["Balance"] = balanceAgent;

                        }
                        else if (Session["Role"].ToString() == "User")
                        {
                            DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                                Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                        }
                        else if (Session["Role"].ToString() == "Admin")
                        {
                            DeductAgentBalance(0, Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                               Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                        }
                    #endregion
                    }
                    else if (Session["Role"] == null)
                    {
                        DeductAgentBalance(0, Convert.ToDouble("0.00"), 0, Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                                  Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                    }

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

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

                    //Do the Insert of Flgiht Segment

                    //  objFlightBal.FlightBookingID = flightBookingId.ToString();
                    if (dsBookingResponse.Tables["FlightSegment"].Rows.Count > 0)
                    {
                        for (int j = 0; j < dsBookingResponse.Tables["FlightSegment"].Rows.Count; j++)
                        {

                            //objFlightBal.Customer_Details = customerInfo;

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

                            bool res1 = objFlightBal.UpdateInternationalFlightSegment(objFlightBal);

                            if (res1)
                            {
                                GetDetailsForPrint(Convert.ToString(Session["Order_Id"]));
                                lbtnmail.Visible = false;
                                pnlSearch.Visible = false;
                                pnlIntPassengerDet.Visible = false;
                                lblMsg.Visible = true;
                                lblMsg.Text = "Ticket has been booked successfully. Reference Number is : " + objFlightBal.ReferenceNo.ToString();
                                lblMsg.ForeColor = System.Drawing.Color.Green;
                                pnlViewticket.Visible = true;
                            }

                        }
                        lbtnmail_Click1(sender, e);

                    }

                }
            }

        }

        catch (NullReferenceException)
        {
            Response.Redirect("~/Default.aspx", false);
        }
        }
 void Mail(string mailId)
 {
     try
     {
         objBAL = new ClsBAL();
         System.Data.DataSet ds = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
         {
             string body = getHTML(pnlTicket);
             bool res = Mailsender.SendEmail(mailId, "", "", "Ticket Details", body);
             if (res)
             {
                 lblMsg.Text = "Ticket Details has been sent to your mail. Please check.";
                 lblMsg.ForeColor = System.Drawing.Color.Green;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void btnIntBookRoundTrip_Click(object sender, EventArgs e)
        {
        try
        {
            GetRoundtripIntBookingRequest();

            Session["Amount"] = lblTotalAmt.Text;

            if (Session["result"].ToString() == "true")
            {
                #region Checking the roles and booking the tickets
                  if (Session["Role"] == null)
                {
                    Response.Redirect("~/pay.aspx?val=true", 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=true", 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", lblairline.Text.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 = lblTotalAmt.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;

                    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", lblairline.Text.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 = lblTotalAmt.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;

                    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 (NullReferenceException)
        {
            Response.Redirect("~/Default.aspx", false);
        }

        }
    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)
        {

        }
    }
        private void saveround(object sender, EventArgs e)
        {
        try
        {
            DataSet dsBookingResponse = new DataSet();
            dsBookingResponse = methodround();

            #region Save Response
            FlightBAL objFlightBal = new FlightBAL();
            if (dsBookingResponse.Tables.Count > 0)
            {
                if (dsBookingResponse.Tables["BookingResponse"].Rows.Count > 0)
                {
                    #region Dedcuting the amount from the agent and DB's balance after booking

                    if (Session["UserID"] != null)
                    {
                        if (Session["Role"] != null)
                        {
                            if (Session["Role"].ToString() == "Agent" || Session["Role"].ToString() == "Distributor")
                            {
                                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()), Session["Order_Id"].ToString(), 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 = balanceAgent;
                                Session["Balance"] = balanceAgent;
                            }
                            else if (Session["Role"].ToString() == "User")
                            {
                                DeductAgentBalance(Convert.ToInt32(Session["AgentId_Agent"].ToString()), Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                                    Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                            }
                            else if (Session["Role"].ToString() == "Admin")
                            {
                                DeductAgentBalance(0, Convert.ToDouble("0.00"), Convert.ToInt32(Session["UserID"].ToString()), Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                                   Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                            }
                        }

                    }
                    else if (Session["Role"] == null)
                    {
                        DeductAgentBalance(0, Convert.ToDouble("0.00"), 0, Session["Order_Id"].ToString(), Convert.ToDouble(Session["Amount"].ToString()),
                                                  Convert.ToDouble("0.00"), Convert.ToDouble("0.00"));
                    }
                    #endregion
                    objFlightBal.ReferenceNo = Convert.ToString(Session["Order_Id"]);// Common.GetFlightsReferenceNo("LJIF");
                    objFlightBal.TransId = dsBookingResponse.Tables["BookingResponse"].Rows[0]["transid"].ToString();
                    objFlightBal.Status = dsBookingResponse.Tables["BookingResponse"].Rows[0]["status"].ToString();
                    objFlightBal.UpdateDInternationalFlightBooking(objFlightBal);

                    GetDetailsForPrint(Convert.ToString(Session["Order_Id"]));
                    lbtnmail.Visible = false;
                    lbtnmail_Click1(sender, e);
                    pnlSearch.Visible = false;
                    pnlViewticket.Visible = true;
                    pnlIntPassengerDet.Visible = false;
                    lblMsg.Visible = true;
                    lblMsg.Text = "Ticket has been booked successfully. Reference Number is : " + Convert.ToString(Session["Order_Id"]);
                    lblMsg.ForeColor = System.Drawing.Color.Green;

                }
            }

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

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

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

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

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

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

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

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

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

        //}

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

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

                //Do the Insert of Flgiht Segment

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

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

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

                        }
                        objFlightBal.Customer_Details = customerInfo;

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

                        bool res1 = objFlightBal.AddInternationalFlightSegment(objFlightBal);

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

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

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

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

                        }

                    }

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

        #endregion
    }
Ejemplo n.º 30
0
    protected void btnDepositUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            ClsBAL objBAL = new ClsBAL();
            System.Data.DataSet ds1 = objBAL.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
            string balance = ds1.Tables[0].Rows[0]["Balance"].ToString();
            if ((Convert.ToDecimal(balance)) > ((Convert.ToDecimal(txtDepositAmount.Text.ToString()) + 25)))
            {

                if ((Convert.ToDecimal(txtDepositAmount.Text.ToString()) >= Convert.ToDecimal("1000"))
                    && (Convert.ToDecimal(txtDepositAmount.Text.ToString())) <= Convert.ToDecimal("25000"))
                {

                    clsMasters _objmasters = new clsMasters();
                    _objmasters.ScreenInd = Masters.Dmr;
                    _objmasters.Amount1 = (Convert.ToDecimal(txtDepositAmount.Text.ToString()));
                    _objmasters.ExtraCharges = Convert.ToDecimal("25");
                    _objmasters.Date = txtChequeIssueDate.Text.ToString();
                    _objmasters.Accountholdername = txtholdername.Text;
                    _objmasters.Accountnumber = txtaccountnumber.Text;
                    _objmasters.IFSCCode = ifsccode.Text;
                    _objmasters.BankName = txtbankname.Text;
                    _objmasters.BranchName = txtbranchname.Text;
                    _objmasters.SenderName = txtsendername.Text;
                    _objmasters.MobileNumber = txtMobileNumber.Text;
                    _objmasters.Status = "No";
                    _objmasters.CreatedBy = Session["UserID"].ToString();

                    ClsBAL objBAL1 = new ClsBAL();
                    System.Data.DataSet ds = objBAL1.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));

                    _objmasters.ID = Convert.ToInt32(ds.Tables[0].Rows[0]["AgentId"].ToString());

                    if (_objmasters.fnInsertRecord() == true)
                    {
                        lblmsg.Text = "Your request submitted  succesfully.";
                        lblmsg.ForeColor = System.Drawing.Color.Green;
                        ClsBAL objBAL2 = new ClsBAL();
                        System.Data.DataSet ds2 = objBAL2.GetAgentByUserId(Convert.ToInt32(Session["UserID"].ToString()));
                        Session["Balance"] = ds2.Tables[0].Rows[0]["Balance"].ToString();

                        Label lbl = (Label)this.Master.FindControl("lblBalance");
                        lbl.Text = Session["Balance"].ToString();

                    //    ClsBAL objBal1 = new ClsBAL();
                    //    string msg = objBal1.DeductAgentDeposit(Convert.ToInt32(Session["UserID"].ToString())
                    //, Convert.ToDouble(txtDepositAmount.Text.ToString()), "", Convert.ToInt32(Session["UserID"].ToString())
                    //, "Dmr", "", "");
                    }
                }
                else
                {
                    lblmsg.Text = "Your transaction amount should be minimum 1000 and maximum 25000.";
                    lblmsg.ForeColor = System.Drawing.Color.Red;
                }

            }
            else
            {
                lblmsg.Text = "Your balance  should be greater than the transfer amount. ";
                lblmsg.ForeColor = System.Drawing.Color.Red;
            }

        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
            lblmsg.ForeColor = System.Drawing.Color.Red;
        }
    }