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