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

using System.IO;

using System.Text;
using System.Collections.Generic;
using System.Net.Mail;

public partial class Transaction_Ticket : System.Web.UI.Page
{
    AirEpointSupport obj_AirEpointSupport;
    string FlightType,final_rule;
    string compName1 = string.Empty;
    string compName2 = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            obj_AirEpointSupport = new AirEpointSupport();
            //Session["partnerrefidtransaction"] = "69265128224947";
            //Session["agid"] = 1304;
            //FlightType = "DOM";
            if (!IsPostBack)
            {
                compName1 = Convert.ToString(Session["agency_name"]);
                compName2 = Convert.ToString(Session["agency_name"]);
                img_logo.ImageUrl = Convert.ToString(Session["agentimage"]);
                lbl_helpemail.Text = Convert.ToString(Session["EMAILID"]);
                img_logo1.ImageUrl = Convert.ToString(Session["agentimage"]);
                lbl_helpemail1.Text = Convert.ToString(Session["EMAILID"]);

                if (Session["partnerrefidtransaction"] == null)
                {
                    Response.Redirect("Trip.aspx");
                 //   Page.ClientScript.RegisterStartupScript(this.GetType(), "aks", "window.open();", true);

                }
                else
                {
                    ViewState["partnerRefId"] = Convert.ToString(Session["partnerrefidtransaction"]);
                    Session.Remove("partnerrefidtransaction");
                }
            }

            flightinfo();
            passinfo();
            GetFlightDetails();
          
    WritePdf();
         
        }
        catch (Exception ex)
        {

            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "PageLoad__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");

        }

    }
    private void flightinfo()
    {
      
        try
        {
            FlightType = obj_AirEpointSupport.getFlightType(Convert.ToString(ViewState["partnerRefId"]),Convert.ToString(Session["HURL"]));
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_getsegmentbyid", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])), new SqlParameter("@userid", Convert.ToString(Session["agid"])), new SqlParameter("@FlightType", FlightType) });

            if (ds.Tables[1].Rows.Count > 0)
            {
                ViewState["journeymode"] = "Return";
                returnticket.Visible = true;
				 string baggage_rule = Convert.ToString(ds.Tables[1].Rows[0]["Rules"]);
                string[] words = baggage_rule.Split('>');
                if (words.Length > 1)
                {
                    string rule_2 = words[1].ToString();
                    string[] words_2 = rule_2.Split('<');
                    final_rule = words_2[0].ToString();
                    tr_bag.Visible = true;
                    //tr_bag.Style.Add("display", "block");
                    lbl_baggage.Text = final_rule;
                }
                else
                {
                   //tr_bag.Style.Add("display", "none");
                    final_rule = "";
                }
            }
            else
            {
                ViewState["journeymode"] = "Depart";
                returnticket.Visible = false;
				 string baggage_rule = Convert.ToString(ds.Tables[0].Rows[0]["Rules"]);
                string[] words = baggage_rule.Split('>');
                if (words.Length > 1)
                {
                    string rule_2 = words[1].ToString();
                    string[] words_2 = rule_2.Split('<');
                    final_rule = words_2[0].ToString();
                    tr_bag.Visible = true;
                    //tr_bag.Style.Add("display", "block");
                    lbl_baggage.Text = final_rule;
                }
                else
                {
                    //tr_bag.Style.Add("display", "none");
                    final_rule = "";
                }
            }
            ViewState["pnrnumber"] = Convert.ToString(ds.Tables[0].Rows[0]["pnrnumber"]);

            string data = "";
            data += "  <table width=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"0\">";
            data += "       <tr bgcolor=\"#FFFFFF\">";
            data += "    <td width=\"12%\" height=\"25\" align=\"center\" valign=\"middle\"  class=\"txt2\" style=\"padding:5px\">";
            data += "    Airline   </td>";
            data += "    <td width=\"12%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"padding:5px\">   Flight Number   </td>";
            data += "     <td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"padding:5px\">    Departure Details </td>";
            data += "<td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:padding:5px\">   Arrival Details </td>";
            data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:padding:5px\">   Ticket PNR    </td>";
            data += "  </tr>";


            ViewState["adultbasefare"] = 0;
            ViewState["childbasefare"] = 0;
            ViewState["infantbasefare"] = 0;
        
                //ViewState["adultbasefare"] = Convert.ToDouble(ViewState["adultbasefare"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["adultFare"]);
                //ViewState["childbasefare"] = Convert.ToDouble(ViewState["childbasefare"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["childFare"]);
            ViewState["adultbasefare"] = Convert.ToDouble(ViewState["adultbasefare"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["ActualBaseFare"]);
            ViewState["childbasefare"] = Convert.ToDouble(ViewState["childbasefare"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["ActualBaseFare"]);
                ViewState["infantbasefare"] = Convert.ToDouble(ViewState["infantbasefare"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["infantFare"]);
           

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {

               
                data += "    <tr bgcolor=\"#FFFFFF\">  <td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"padding:5px\">";
                if (FlightType == "DOM" || FlightType == "INAIR")
                {
                    string flightName = string.Empty;
                    if (i == 0)
                    {
                        string opcode = ds.Tables[0].Rows[i]["airLineName"].ToString();
                        DataSet ds1 = obj_AirEpointSupport.GetAirImageDetails();
                        var imageurl = from ImgurlDetail in ds1.Tables["AirLineImageUrlDetail"].AsEnumerable()
                                       where ImgurlDetail.Field<string>("AirlineCode") == Convert.ToString(opcode)
                                       select new
                                       {
                                           airlinename = ImgurlDetail["AirlineName"].ToString()
                                       };
                        if (imageurl.Count() > 0)
                        {

                            flightName = imageurl.AsEnumerable().ElementAt(0).airlinename;
                        }
                    }
                    data += flightName + "   </td>";
                }
                data += "<td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";
                data += ds.Tables[0].Rows[i]["OperatingAirlineCode"] + "-" + ds.Tables[0].Rows[i]["FlightNumber"] + "</td>";


                data += "<td width=\"10%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";
                data += Convert.ToString(ds.Tables[0].Rows[i]["DepartureAirportCode"]) + "</td>";




                data += "<td width=\"14%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";
                data += DateTime.Parse(Convert.ToString(ds.Tables[0].Rows[i]["DepartureDateTime"])).ToString("ddd, MMM d, yyyy") + "</td>";
                data += "<td width=\"7%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";
                data += Convert.ToDateTime(ds.Tables[0].Rows[i]["DepartureDateTime"].ToString()).ToShortTimeString() + "</td>";


                data += "<td width=\"10%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";
                data += Convert.ToString(ds.Tables[0].Rows[i]["ArrivalAirportCode"]) + "</td>";




                data += "<td width=\"14%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:padding:5px\">";

                data += DateTime.Parse(Convert.ToString(ds.Tables[0].Rows[i]["ArrivalDateTime"])).ToString("ddd, MMM d, yyyy") + "</td>";

                data += "<td width=\"7%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"padding:5px\">";
                data += Convert.ToDateTime(ds.Tables[0].Rows[i]["ArrivalDateTime"].ToString()).ToShortTimeString() + "</td>";
                data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"padding:5px\">";
                data += Convert.ToString(ds.Tables[0].Rows[i]["pnrnumber"]);
                data += " </td>";
                data += "  </tr>";
            }
            data += " </table>";

            literal_flightinfo.Text = data;


            //_____________________
            if (Convert.ToString(ViewState["journeymode"]) == "Return")
            {

                ViewState["pnrnumber_return"] = Convert.ToString(ds.Tables[1].Rows[0]["pnrnumber"]);


                data = "";
                data += "  <table width=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"0\">";
                data += "       <tr bgcolor=\"#FFFFFF\">";
                data += "    <td width=\"12%\" height=\"25\" align=\"center\" valign=\"middle\"  class=\"txt2\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                data += "    Airline   </td>";
                data += "    <td width=\"12%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">   Flight Number   </td>";
                data += "     <td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">    Departure Details </td>";
                data += "<td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">   Arrival Details </td>";
                data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border-top:0px solid #CACACA;border-left:0px solid #CACACA;padding:5px\">   Ticket PNR    </td>";
                data += "  </tr>";


                ViewState["adultbasefare_return"] = 0;
                ViewState["childbasefare_return"] = 0;
                ViewState["infantbasefare_return"] = 0;


                //ViewState["adultbasefare_return"] = Convert.ToDouble(ViewState["adultbasefare_return"]) + Convert.ToDouble(ds.Tables[1].Rows[0]["adultFare"]);
                //ViewState["childbasefare_return"] = Convert.ToDouble(ViewState["childbasefare_return"]) + Convert.ToDouble(ds.Tables[1].Rows[0]["childFare"]);
                ViewState["adultbasefare_return"] = Convert.ToDouble(ViewState["adultbasefare_return"]) + Convert.ToDouble(ds.Tables[1].Rows[0]["ActualBaseFare"]);
                ViewState["childbasefare_return"] = Convert.ToDouble(ViewState["childbasefare_return"]) + Convert.ToDouble(ds.Tables[1].Rows[0]["ActualBaseFare"]);
                ViewState["infantbasefare_return"] = Convert.ToDouble(ViewState["infantbasefare_return"]) + Convert.ToDouble(ds.Tables[1].Rows[0]["infantFare"]);
                for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                {




                    data += "    <tr bgcolor=\"#FFFFFF\">  <td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:0px solid #CACACA;padding:5px\">";
                    if (FlightType == "DOM" || FlightType == "INAIR")
                    {
                        string flightName = string.Empty;
                        if (i == 0)
                        {
                            string opcode = ds.Tables[1].Rows[i]["airLineName"].ToString();
                            DataSet ds1 = obj_AirEpointSupport.GetAirImageDetails();
                            var imageurl = from ImgurlDetail in ds1.Tables["AirLineImageUrlDetail"].AsEnumerable()
                                           where ImgurlDetail.Field<string>("AirlineCode") == Convert.ToString(opcode)
                                           select new
                                           {
                                               airlinename = ImgurlDetail["AirlineName"].ToString()
                                           };
                            if (imageurl.Count() > 0)
                            {
                                flightName = imageurl.AsEnumerable().ElementAt(0).airlinename;
                            }
                        }
                        data += flightName + "   </td>";
                    }
                  //  data += ds.Tables[1].Rows[i]["airLineName"].ToString() + "   </td>";
                    data += "<td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += ds.Tables[1].Rows[i]["OperatingAirlineCode"] + "-" + ds.Tables[1].Rows[i]["FlightNumber"] + "</td>";


                    data += "<td width=\"10%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += Convert.ToString(ds.Tables[1].Rows[i]["DepartureAirportCode"]) + "</td>";




                    data += "<td width=\"14%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += DateTime.Parse(Convert.ToString(ds.Tables[1].Rows[i]["DepartureDateTime"])).ToString("ddd, MMM d, yyyy") + "</td>";
                    data += "<td width=\"7%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += Convert.ToDateTime(ds.Tables[1].Rows[i]["DepartureDateTime"].ToString()).ToShortTimeString() + "</td>";


                    data += "<td width=\"10%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += Convert.ToString(ds.Tables[1].Rows[i]["ArrivalAirportCode"]) + "</td>";




                    data += "<td width=\"14%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";

                    data += DateTime.Parse(Convert.ToString(ds.Tables[1].Rows[i]["ArrivalDateTime"])).ToString("ddd, MMM d, yyyy") + "</td>";

                    data += "<td width=\"7%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += Convert.ToDateTime(ds.Tables[1].Rows[i]["ArrivalDateTime"].ToString()).ToShortTimeString() + "</td>";
                    data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border-top:0px solid #CACACA;border-left:1px solid #CACACA;padding:5px\">";
                    data += Convert.ToString(ds.Tables[1].Rows[i]["pnrnumber"]);
                    data += " </td>";
                    data += "  </tr>";
                }
                data += " </table>";

                literal_flightinfo_return.Text = data;
            }


        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "flightinfo__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");
        }

         

    }


    private void WritePdf()
    {
     
        try
        {
            string html1;

            html1 = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />    
    <link href='http://venusrecharge.in/css/mystyle.css' rel='stylesheet' type='text/css' />
    <style type='text/css'>
        .txt11
        {
            font-family: 'Trebuchet MS';
            font-size: 12px;
            color: #000000;
            text-decoration: none;
        }
 </style>
<script type='text/javascript'>
windows.print();
</script>
</head>
<body>
    <form id='form1' runat='server'>";

          string  html = @"<table class='master_table' cellpadding='0' cellspacing='0'>
        <tr>
<td colspan='100%' valign='top'>

<table class='inner_tbl' cellpadding='0' cellspacing='0'>
<tr>
<td width='10%' valign='top'><div id='air_logo_3'>
                    <img src='" + img_logo.ImageUrl + @"' width='190' height='90' /></div></td>
<td valign='top'>
<table cellpadding='0' cellspacing='0' class='text_info' style='float:right;'>
<tr>
<td><strong>Agency</strong></td><td>:</td><td>" +Convert.ToString(Session["agency_name"])+@"</td>
</tr>
<tr>
<td><strong>Contact</strong></td><td>:</td><td>" + Convert.ToString(Session["MobileNo"]) + @"</td>
</tr>
<tr>
<td><strong>Email ID</strong></td><td>:</td><td>" + lbl_helpemail.Text + @"</td>
</tr>
</table></td>
</tr>
<table class='tckt_tbl' cellpadding='0' cellspacing='0' style='border-bottom:none;'>

<tr bgcolor='#F0F8FF'>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Airline :</strong>" + lbl_flightoperatorcode.Text+@"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>PNR :</strong> "+lbl_pnrnumber.Text+@"</td>
 </tr>
 <tr>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Flight :</strong>"+lbl_source.Text+@"
                                -&gt;
                                "+lbl_destination.Text+@"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>Journey Date :</strong>"+lbl_departdate.Text+@"</td>
 </tr>
 <tr bgcolor='#F0F8FF'>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Booking Date :</strong>"+lbl_bookingdate.Text+@"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>Ref No :</strong>"+lbl_Arzoo_RefNo.Text+@"</td>
 </tr>
<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA; font-size:10px;line-height:15px;'>
Your booking for above mentioned flight is confirmed. Your reference number is " + lbl_partnerrefid.Text + @". Please use this reference number for all future communications with your booking agent. If you require any further assistance, please contact your booking agent.
</td>

 </tr>
</table>
<table class='tckt_tbl' cellpadding='0' cellspacing='0' style=border-bottom:none;border-top:none;'>
<tr>
<td colspan='100%' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;' align='center'>
<strong>Flight Details (Depart)</strong>
</td>
 </tr>
<tr bgcolor='#F0F8FF'>
<td colspan='2' align='center'>" +literal_flightinfo.Text+@"</td>
 </tr>
 
 <tr>

 </tr>

<tr>

 </tr>

<tr>

 </tr>
 
</table>

<table class='tckt_tbl' cellpadding='0' cellspacing='0' id='tblpassinfo' runat='server' style='border-bottom:none; border-top:none;'>
<tr>
<td colspan='100%' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;' align='center'>
<strong>Passenger Details (Depart)</strong>
</td>
 </tr>
<tr>
                        <td align='center' valign='middle'>
                            Sr. No.
                        </td>
                        <td align='center' valign='middle'>
                            Passenger Name(s)
                        </td>
                        <td align='center' valign='middle'>
                            Type
                        </td>
                        <td align='center' valign='middle'>
                            Age
                        </td>
                        <td align='center' valign='middle'>
                            Ticket PNR
                        </td>
                    </tr>";

            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_get_pass_info", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])) });


            for (int i = 1; i <= ds.Tables[0].Rows.Count; i++)
            {



                html += @"   <tr>
                        <td align='center' valign='middle'>" + i.ToString() + @"
                           
                        </td>
                        <td align='center' valign='middle'>" +
                                    ds.Tables[0].Rows[i - 1]["Title"].ToString() + " " + ds.Tables[0].Rows[i - 1]["FirstName"].ToString() + " " + ds.Tables[0].Rows[i - 1]["LastName"].ToString() + @"
                        </td>
                        <td align='center' valign='middle'>" +
                                   ds.Tables[0].Rows[i - 1]["type"].ToString() + @"
                        </td>
                        <td align='center' valign='middle'>";
                if (ds.Tables[0].Rows[i - 1]["type"].ToString() == "ADULT")
                {
                    html += "--";
                }
                else
                {
                    html += ds.Tables[0].Rows[i - 1]["Age"].ToString();
                }
                   html += @"
                        </td>
                        <td align='center' valign='middle'>";

                if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Processed")
                {
                   html+="Cancelled";


                }
                else if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
                {
                       html+= "Cancellation Under Process";


                }
                else
                {


                      html+= ViewState["pnrnumber"].ToString();  // ds.Tables[0].Rows[i - 1]["eticketno"].ToString();

                }


             
                      html+= @"
                        </td>
                    </tr>";

            }







            html = html + @"  
                </table>
            </td>
        </tr>
        <tr>
         
            <td width='100%'>
                <table width='100%' border='0' cellpadding='0' cellspacing='0' class='txt2'>
                    <tr>
                        <td colspan='4' align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'>
                            Fare Details
                        </td>
                    </tr>
                    <tr bgcolor='#F0F8FF'>
                        <td width='35%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Passenger Type
                        </td>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;'>
                            <span style='padding-left: 10px'><strong>No of Passenger</strong></span>
                        </td>
                        <td style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;' align='center' valign='middle'>
                            <span style='padding-left: 10px'><strong>Basic Fare</strong></span>
                        </td>
                        <td style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;' width='28%' align='center' valign='middle'>
                            <strong>Fare Details</strong>
                        </td>
                    </tr>
                    <tr>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Adult
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>" + lbl_fare_noofadulf.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                           " + lbl_fare_adultbasefare.Text + @"
                        </td>
                    </tr>";
            if(lbl_fare_noofchild.Text!="0")
            {
                html=html+ @" <tr runat='server' id='row_fare_child' visible='false'>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Child
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>" + lbl_fare_noofchild.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                           " + lbl_fare_childbasefare.Text + @"
                        </td>
                    </tr>";
            }

            if(lbl_fare_noofinfant.Text!="0")
            {
                html=html+ @"<tr runat='server' id='row_fare_infant' visible='false'>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Infant
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>" + lbl_fare_noofinfant.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;'>
                            " + lbl_fare_infantbasefare.Text + @"
                        </td>
                    </tr>";
            }


                   
                    
                    html=html+ @"<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;'   align='center'><strong></strong></td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Total Basic Fare &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_totalbasefare.Text + @"</td>
</tr>

<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;' align='center' bgcolor='#F0F8FF'><strong>Important Instructions</strong></td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Air Port Tax &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_airporttax.Text + @"</td>
</tr>

<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;font-size:11px;line-height:15px; text-align:left;' width='25%'   align='center'>Passenger is requested to check-in 2 hours prior to scheduled departure.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Sevice Tax & Fees &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_servicetaxfee.Text + @"</td>
</tr>

<tr>
<td bgcolor='#F0F8FF' colspan='2' rowspan='3' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA;font-size:11px;line-height:15px; text-align:left;'   align='center'>All Passengers including children and infants must present valid identity proof (Passport / Pan Card / election card or any photo identity proof) at the time of check-in. It is your responsibility to ensure you have the appropriate travel documents at all times.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Fare (Including Fees & Taxes) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_fare.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Discount &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_discount.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;;'  width='25%' align='right'><strong>Miscellaneous &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_misc.Text + @"</td>
</tr>

<tr>
<td colspan='2' rowspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA; font-size:11px;line-height:15px; text-align:left;'   align='center'>Changes/Cancellations to booking must be made at least 5 hours prior to scheduled departure time or else should be cancelled directly from the respective airlines.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Fare (After Discount) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_fareafterdiscount.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Payment Gateway Charges &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;' width='15%' align='center'>" + lbl_fare_pg_charges.Text + @"</td>
</tr>

<tr>
<td bgcolor='#F0F8FF' colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;border-bottom:1px solid #CACACA; font-size:11px;line-height:15px; text-align:left;'   align='center'>If any flight is cancelled or rescheduled by the airline authority, passenger is requested to get a stamped/endorsed copy of the ticket to process the refund.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;border-bottom:1px solid #CACACA;'  width='25%' align='right'><strong>Total Fare (Payable to Agent) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;border-bottom:1px solid #CACACA;;' width='15%' align='center'>" + lbl_fare_totalpayable.Text + @"</td>
</tr>
                </table>

</td>
</tr>

 <tr>
            <td colspan='2'>
                &nbsp;
            </td>
        </tr>
</table>";


       
    
   
   html1=html1+ @"</form>
</body>
</html>";

                    string msg= @"
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
   <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link href='http://venusrecharge.in/css/mystyle.css' rel='stylesheet' type='text/css' />
<style type='text/css'>
.txt_1 {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 16px;
	font-weight: bold;
	color: #000;
}

.txt_2 {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 13px;
	font-weight: normal;
	color: #000;
}

.txt_3 {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
	font-weight: normal;
	color: #000;
}
</style>
</head>
<body>
<table width='980' border='0' align='center' cellpadding='0' cellspacing='0'>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height='30' align='left' valign='top'><p class='txt_2'>Dear Sir/madam,</p></td>
  </tr>
   
   <tr>
   <td height='20' align='left' valign='top'><p class='txt_2'> Your flight booking is 
        confirmed against reference number " + Convert.ToString(ViewState["partnerRefId"]) + @". Please find attachment 
        and use this reference number for all future communications with us. If you 
        require any further assistance, please Contact Us.
</p></td>
  </tr>
</table>";
msg=msg+html;
msg=msg+@"</body>
</html>
";

            MailMessage message = new MailMessage();

            message.Body = msg;
            message.IsBodyHtml = true;

           // message.To.Add(Convert.ToString(Session["email_id"]));
            
            message.To.Add("aloksingh17.88@gmail.com");


            message.From = new MailAddress(Convert.ToString(Session["EMAILID"]));
            message.Subject = "Air Ticket Booking";
            message.Priority = MailPriority.High;



            //var a = Attachment.CreateAttachmentFromString(html, "Ticket.html");
            //message.Attachments.Add(a);

            if (Convert.ToString(ViewState["journeymode"]) == "Return")
            {
                var b = Attachment.CreateAttachmentFromString(WritePdf_Return(), "Return Ticket.html");
                message.Attachments.Add(b); 
            }
            

            SmtpClient SmtpMail = new SmtpClient();
            {

                //SmtpMail.Host = "mail.eservices.net.in";
                //SmtpMail.Port = 25;
                //SmtpMail.EnableSsl = false;
                //SmtpMail.UseDefaultCredentials = true;
                //SmtpMail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                //SmtpMail.Credentials = new System.Net.NetworkCredential("noreply@eservices.net.in", "admin@yahoo.123");
                //SmtpMail.Send(message);
                SmtpMail.Host = "smtp.gmail.com";
                SmtpMail.Port = 587;
                SmtpMail.EnableSsl = true;
                SmtpMail.UseDefaultCredentials = true;
                SmtpMail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                SmtpMail.Credentials = new System.Net.NetworkCredential("venusutilityservices@gmail.com", "Venus@123");
                SmtpMail.Send(message);
            }

        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "(War10ck)Write PDF__" + Convert.ToString(ViewState["partnerRefId"]));
              }

      
    }

    private string  WritePdf_Return()
    {
       
        try
        {
            string html;

            html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />    
    <link href='http://intlair.travelepoint.in/css/mystyle.css' rel='stylesheet' type='text/css' />
    <style type='text/css'>
        .txt11
        {
            font-family: 'Trebuchet MS';
            font-size: 12px;
            color: #000000;
            text-decoration: none;
        }
 </style>
<script type='text/javascript'>
windows.print();
</script>
</head>
<body>
    <form id='form1' runat='server'>
    <table class='master_table' cellpadding='0' cellspacing='0'>
        <tr>
<td colspan='100%' valign='top'>

<table class='inner_tbl' cellpadding='0' cellspacing='0'>
<tr>
<td width='10%' valign='top'><div id='air_logo_3'>
                    
                    <img src='" + img_logo1.ImageUrl + @"' width='190' height='90' />    
                  </div></td>
<td valign='top'>
<table cellpadding='0' cellspacing='0' class='text_info' style='float:right;'>
<tr>
<td><strong>Agency</strong></td><td>:</td><td>" + Convert.ToString(Session["agency_name"]) + @"</td>
</tr>
<tr>
<td><strong>Contact</strong></td><td>:</td><td>" + Convert.ToString(Session["mobile_no"]) + @"</td>
</tr>
<tr>
<td><strong>Email ID</strong></td><td>:</td><td>" + lbl_helpemail.Text + @"</td>
</tr>
</table></td>
</tr>

<table class='tckt_tbl' cellpadding='0' cellspacing='0' style='border-bottom:none;'>

<tr bgcolor='#F0F8FF'>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Airline :</strong>" + lbl_flightoperatorcode_return.Text + @"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>PNR :</strong> " + lbl_pnrnumber_return.Text + @"</td>
 </tr>
 <tr>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Flight :</strong>" + lbl_source_return.Text + @"
                                -&gt;
                                " + lbl_destination_return.Text + @"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>Journey Date :</strong>" + lbl_departdate_return.Text + @"</td>
 </tr>
 <tr bgcolor='#F0F8FF'>
<td style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'  width='50%' align='center'><strong>Booking Date :</strong>" + lbl_bookigdate_return.Text + @"</td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='50%' align='center'><strong>Ref No :</strong>" + lbl_Arzoo_RefNo_return.Text + @"</td>
 </tr>
<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA; font-size:10px;line-height:15px;'>
Your booking for above mentioned flight is confirmed. Your reference number is " + lbl_partnerrefid_return.Text + @". Please use this reference number for all future communications with your booking agent. If you require any further assistance, please contact your booking agent.
</td>

 </tr>
</table>
<table class='tckt_tbl' cellpadding='0' cellspacing='0' style=border-bottom:none;border-top:none;'>
<tr>
<td colspan='100%' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;' align='center'>
<strong>Flight Details (Return)</strong>
</td>
 </tr>
<tr bgcolor='#F0F8FF'>
<td colspan='2' align='center'>" + literal_flightinfo_return.Text + @"</td>
 </tr>
 
 <tr>

 </tr>

<tr>

 </tr>

<tr>

 </tr>
 
</table>

<table class='tckt_tbl' cellpadding='0' cellspacing='0' id='tblpassinfo' runat='server' style='border-bottom:none; border-top:none;'>
<tr>
<td colspan='100%' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;' align='center'>
<strong>Passenger Details (Return)</strong>
</td>
 </tr>
<tr>
                        <td align='center' valign='middle'>
                            Sr. No.
                        </td>
                        <td align='center' valign='middle'>
                            Passenger Name(s)
                        </td>
                        <td align='center' valign='middle'>
                            Type
                        </td>
                        <td align='center' valign='middle'>
                            Age
                        </td>
                        <td align='center' valign='middle'>
                            Ticket PNR
                        </td>
                    </tr>";

            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_get_pass_info", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])) });


            for (int i = 1; i <= ds.Tables[1].Rows.Count; i++)
            {



                html += @"   <tr>
                        <td align='center' valign='middle'>" + i.ToString() + @"
                           
                        </td>
                        <td align='center' valign='middle'>" +
                                    ds.Tables[1].Rows[i - 1]["Title"].ToString() + " " + ds.Tables[1].Rows[i - 1]["FirstName"].ToString() + " " + ds.Tables[1].Rows[i - 1]["LastName"].ToString() + @"
                        </td>
                        <td align='center' valign='middle'>" +
                                   ds.Tables[1].Rows[i - 1]["type"].ToString() + @"
                        </td>
                        <td align='center' valign='middle'>";
                if (ds.Tables[1].Rows[i - 1]["type"].ToString() == "ADULT")
                {
                    html += "--";
                }
                else
                {
                    html += ds.Tables[1].Rows[i - 1]["Age"].ToString();
                }
                html += @"
                        </td>
                        <td align='center' valign='middle'>";

                if (ds.Tables[1].Rows[i - 1]["CancellationStatus"].ToString() == "Processed")
                {
                    html += "Cancelled";


                }
                else if (ds.Tables[1].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
                {
                    html += "Cancellation Under Process";


                }
                else
                {


                    html += ViewState["pnrnumber"].ToString();  // ds.Tables[0].Rows[i - 1]["eticketno"].ToString();

                }



                html += @"
                        </td>
                    </tr>";

            }







            html = html + @"  
                </table>
            </td>
        </tr>
        <tr>
         
            <td width='100%'>
                <table width='100%' border='0' cellpadding='0' cellspacing='0' class='txt2'>
                    <tr>
                        <td colspan='4' align='center' valign='middle' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'>
                            Fare Details
                        </td>
                    </tr>
                    <tr bgcolor='#F0F8FF'>
                        <td width='35%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Passenger Type
                        </td>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;'>
                            <span style='padding-left: 10px'><strong>No of Passenger</strong></span>
                        </td>
                        <td style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;' align='center' valign='middle'>
                            <span style='padding-left: 10px'><strong>Basic Fare</strong></span>
                        </td>
                        <td style='border-top:1px solid #CACACA;border-left:1px solid #CACACA;' width='28%' align='center' valign='middle'>
                            <strong>Fare Details</strong>
                        </td>
                    </tr>
                    <tr>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Adult
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>" + lbl_fare_noofadulf_return.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            " + lbl_fare_adultbasefare_return.Text + @"
                        </td>
                    </tr>";
            if (lbl_fare_noofchild_return.Text != "0")
            {
                html = html + @" <tr runat='server' id='row_fare_child' visible='false'>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Child
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>" + lbl_fare_noofchild_return.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            " + lbl_fare_childbasefare_return.Text + @"
                        </td>
                    </tr>";
            }

            if (lbl_fare_noofinfant_return.Text != "0")
            {
                html = html + @"<tr runat='server' id='row_fare_infant' visible='false'>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Infant
                        </td>
                        <td width='17%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>" + lbl_fare_noofinfant_return.Text + @"
                        </td>
                        <td width='20%' align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                            Basic Fare:
                        </td>
                        <td align='center' valign='middle' style='border-top:1px solid #CACACA;border-left:0px solid #CACACA;'>
                           " + lbl_fare_infantbasefare_return.Text + @"
                        </td>
                    </tr>";
            }




            html = html + @"<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;'   align='center'><strong></strong></td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Total Basic Fare &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_totalbasefare_return.Text + @"</td>
</tr>

<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;' align='center' bgcolor='#F0F8FF'><strong>Important Instructions</strong></td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Air Port Tax &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_airporttax_return.Text + @"</td>
</tr>

<tr>
<td colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;font-size:11px;line-height:15px; text-align:left;' width='25%'   align='center'>Passenger is requested to check-in 2 hours prior to scheduled departure.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Sevice Tax & Fees &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_servicetaxfee_return.Text + @"</td>
</tr>

<tr>
<td bgcolor='#F0F8FF' colspan='2' rowspan='3' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA;font-size:11px;line-height:15px; text-align:left;'   align='center'>All Passengers including children and infants must present valid identity proof (Passport / Pan Card / election card or any photo identity proof) at the time of check-in. It is your responsibility to ensure you have the appropriate travel documents at all times.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Fare (Including Fees & Taxes) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_fare_return.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Discount &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_discount_return.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Miscellaneous &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_misc_return.Text + @"</td>
</tr>

<tr>
<td colspan='2' rowspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA; font-size:11px;line-height:15px; text-align:left;'   align='center'>Changes/Cancellations to booking must be made at least 5 hours prior to scheduled departure time or else should be cancelled directly from the respective airlines.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Fare (After Discount) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_fareafterdiscount_return.Text + @"</td>
</tr>

<tr>

<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Payment Gateway Charges &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_pg_charges_return.Text + @"</td>
</tr>

<tr>
<td bgcolor='#F0F8FF' colspan='2' style='border-top:0px solid #CACACA;border-left:0px solid #CACACA; font-size:11px;line-height:15px; text-align:left;'   align='center'>If any flight is cancelled or rescheduled by the airline authority, passenger is requested to get a stamped/endorsed copy of the ticket to process the refund.</td>
<td style='border-top:0px solid #CACACA;border-left:1px solid #CACACA;'  width='25%' align='right'><strong>Total Fare (Payable to Agent) &nbsp;&nbsp;</strong></td>
<td style='border-top:0px solid #CACACA;border-right:0px solid #CACACA;' width='15%' align='center'>" + lbl_fare_totalpayable_return.Text + @"</td>
</tr>
                </table>

</td>
</tr>

 <tr>
            <td colspan='2'>
                &nbsp;
            </td>
        </tr>
</table>


       
    
   
    </form>
</body>
</html>";



                return html;
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "Write PDF Return__" + Convert.ToString(ViewState["partnerRefId"]));
            return "";
       
        }

    }

    private void passinfo()
    {
        
        try
        {

            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_get_pass_info", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])) });

            for (int i = 1; i <= ds.Tables[0].Rows.Count; i++)
            {



                ((HtmlTableRow)(tblpassinfo.FindControl("pass" + i.ToString()))).Visible = true;
                ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_name"))).Text = ds.Tables[0].Rows[i - 1]["Title"].ToString() + " " + ds.Tables[0].Rows[i - 1]["FirstName"].ToString() + " " + ds.Tables[0].Rows[i - 1]["LastName"].ToString();

                if (ds.Tables[0].Rows[i - 1]["type"].ToString() == "ADULT")
                {
                    ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_age"))).Text = "--";
                }
                else
                {
                    ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_age"))).Text = ds.Tables[0].Rows[i - 1]["Age"].ToString();
                }
                ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_type"))).Text = ds.Tables[0].Rows[i - 1]["type"].ToString();


               if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Processed")
                 {
                    ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_eticketno"))).Text = "Cancelled";


             }
                  else                 if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
                {
                    ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_eticketno"))).Text = "Cancellation Under Process";


                 }
                 else
                {


                ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_eticketno"))).Text = ViewState["pnrnumber"].ToString();  // ds.Tables[0].Rows[i - 1]["eticketno"].ToString();

                 }



            }

            //________
            if (Convert.ToString(ViewState["journeymode"]) == "Return")
            {

                for (int i = 1; i <= ds.Tables[1].Rows.Count; i++)
                {



                    ((HtmlTableRow)(tblpassinfo_return.FindControl("pass" + i.ToString() + "_return"))).Visible = true;
                    ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_name_return"))).Text = ds.Tables[1].Rows[i - 1]["Title"].ToString() + " " + ds.Tables[1].Rows[i - 1]["FirstName"].ToString() + " " + ds.Tables[1].Rows[i - 1]["LastName"].ToString();

                    if (ds.Tables[1].Rows[i - 1]["type"].ToString() == "ADULT")
                    {
                        ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_age_return"))).Text = "--";
                    }
                    else
                    {
                        ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_age_return"))).Text = ds.Tables[1].Rows[i - 1]["Age"].ToString();
                    }
                    ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_type_return"))).Text = ds.Tables[1].Rows[i - 1]["type"].ToString();


                    if (ds.Tables[1].Rows[i - 1]["CancellationStatus"].ToString() == "Processed")
                    {
                        ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_eticketno_return"))).Text = "Cancelled";


                    }
                    else if (ds.Tables[1].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
                    {
                        ((Label)(tblpassinfo.FindControl("lbl_pass" + i.ToString() + "_eticketno_return"))).Text = "Cancellation Under Process";


                    }
                    else
                    {


                        ((Label)(tblpassinfo_return.FindControl("lbl_pass" + i.ToString() + "_eticketno_return"))).Text = ViewState["pnrnumber_return"].ToString();  // ds.Tables[0].Rows[i - 1]["eticketno"].ToString();

                    }



                }
            }
        }
        catch (Exception ex)
        {

            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "Pass info__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");

        }
           

    }

    void GetFlightDetails()
    {
     
        try
        {
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_GetFligthDetails1", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])), new SqlParameter("@UserId", Convert.ToString(Session["agid"])), new SqlParameter("@FlightType", FlightType) });


        lbl_source.Text = ds.Tables[0].Rows[0]["Origin"].ToString();
        //lbl_source1.Text = ds.Tables[0].Rows[0]["Origin"].ToString();   //Alok
        lbl_destination.Text = ds.Tables[0].Rows[0]["Destination"].ToString();
       // lbl_destination1.Text = ds.Tables[0].Rows[0]["Destination"].ToString();   //Alok
        lbl_departdate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["DepartDate"].ToString()).ToString("dd MMM,yyyy");
   //     lbl_departdate1.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["DepartDate"].ToString()).ToString("dd MMM,yyyy");



        lbl_partnerrefid.Text = Convert.ToString(ViewState["partnerRefId"]);
        lbl_pnrnumber.Text=Convert.ToString(ViewState["pnrnumber"] );
        //lbl_pnrnumber1.Text = Convert.ToString(ViewState["pnrnumber"]);   //Alok


        int adult = Convert.ToInt16( ds.Tables[0].Rows[0]["AdultPax"]);
        int child= Convert.ToInt16(ds.Tables[0].Rows[0]["ChildPax"]);
        int infant = Convert.ToInt16(ds.Tables[0].Rows[0]["InfantPax"]);
        lbl_fare_noofchild.Text=child.ToString();
        lbl_fare_noofinfant.Text=infant.ToString();
        lbl_fare_noofadulf.Text=adult.ToString();
       

//==================================================================================================
       
        lbl_fare_adultbasefare.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["adultbasefare"])).ToString() + " x " + adult.ToString();
        lbl_fare_childbasefare.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["childbasefare"])).ToString() + " x " + child.ToString();
        lbl_fare_infantbasefare.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["infantbasefare"])).ToString() + " x " + infant.ToString();
        double TotalBaseFare=(Convert.ToDouble(Session["convertor"])*((Convert.ToDouble(ViewState["adultbasefare"])*adult)+(Convert.ToDouble(ViewState["childbasefare"])*child)+(Convert.ToDouble(ViewState["infantbasefare"])*infant)));
        lbl_fare_totalbasefare.Text = Convert.ToString(TotalBaseFare);
        lbl_fare_airporttax.Text = (((Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[0]["Tax"])) * (adult + child + infant))).ToString();
        double tcharge = Convert.ToDouble(ds.Tables[0].Rows[0]["TCharge"].ToString());
        double servicetas = Convert.ToDouble(ds.Tables[0].Rows[0]["STax"].ToString())+tcharge;
        lbl_fare_servicetaxfee.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(servicetas)).ToString();
        lbl_fare_fare.Text = Convert.ToString(TotalBaseFare + Convert.ToDouble(lbl_fare_airporttax.Text) + Convert.ToDouble(lbl_fare_servicetaxfee.Text));

        lbl_fare_discount.Text = Convert.ToString(Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[0]["TDiscount"]));

        lbl_misc.Text = Convert.ToString(Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[0]["Other_Tax"]));
        lbl_fare_fareafterdiscount.Text = Convert.ToString((Convert.ToDouble(lbl_fare_fare.Text) + Convert.ToDouble(lbl_misc.Text)) - Convert.ToDouble(lbl_fare_discount.Text));
        lbl_fare_pg_charges.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble("0")).ToString();
        lbl_fare_totalpayable.Text = Session["Currency"].ToString() + " " + Convert.ToString(lbl_fare_fareafterdiscount.Text);
        if (child > 0)
        {
            row_fare_child.Visible = true;
        }
        if (infant > 0)
        {
            row_fare_infant.Visible = true;
        }


     
        //_________________
        if (Convert.ToString(ViewState["journeymode"]) == "Return")
        {


            lbl_source_return.Text = ds.Tables[0].Rows[1]["Origin"].ToString();
           // lbl_source1_return.Text = ds.Tables[0].Rows[1]["Origin"].ToString();   //Alok
            lbl_destination_return.Text = ds.Tables[0].Rows[1]["Destination"].ToString();
           // lbl_destination1_return.Text = ds.Tables[0].Rows[1]["Destination"].ToString();   //Alok
            lbl_departdate_return.Text = Convert.ToDateTime(ds.Tables[0].Rows[1]["DepartDate"].ToString()).ToString("dd MMM,yyyy");
         //   lbl_departdate1_return.Text = Convert.ToDateTime(ds.Tables[0].Rows[1]["DepartDate"].ToString()).ToString("dd MMM,yyyy");



            lbl_partnerrefid_return.Text = Convert.ToString(ViewState["partnerRefId"]);
            lbl_pnrnumber_return.Text = Convert.ToString(ViewState["pnrnumber_return"]);
           // lbl_pnrnumber1_return.Text = Convert.ToString(ViewState["pnrnumber_return"]);   //Alok


            int adult_return = Convert.ToInt16(ds.Tables[0].Rows[1]["AdultPax"]);
            int child_return = Convert.ToInt16(ds.Tables[0].Rows[1]["ChildPax"]);
            int infant_return = Convert.ToInt16(ds.Tables[0].Rows[1]["InfantPax"]);
            lbl_fare_noofchild_return.Text = child_return.ToString();
            lbl_fare_noofinfant_return.Text = infant_return.ToString();
            lbl_fare_noofadulf_return.Text = adult_return.ToString();


            lbl_fare_adultbasefare_return.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["adultbasefare_return"])).ToString() + " x " + adult_return.ToString();
            lbl_fare_childbasefare_return.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["childbasefare_return"])).ToString() + " x " + child_return.ToString();
            lbl_fare_infantbasefare_return.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ViewState["infantbasefare_return"])).ToString() + " x " + infant_return.ToString();
            double TotalBaseFare_return = (Convert.ToDouble(Session["convertor"]) * ((Convert.ToDouble(ViewState["adultbasefare_return"]) * adult_return) + (Convert.ToDouble(ViewState["childbasefare_return"]) * child_return) + (Convert.ToDouble(ViewState["infantbasefare_return"]) * infant_return)));
            lbl_fare_totalbasefare_return.Text = Convert.ToString(TotalBaseFare_return);
            lbl_fare_airporttax_return.Text = (((Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[1]["Tax"])) * (adult_return + child_return + infant_return))).ToString();
            double tcharge_return = Convert.ToDouble(ds.Tables[0].Rows[1]["TCharge"].ToString());
            double servicetas_return = Convert.ToDouble(ds.Tables[0].Rows[1]["STax"].ToString()) + tcharge;
            lbl_fare_servicetaxfee_return.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(servicetas_return)).ToString();
            lbl_fare_fare_return.Text = Convert.ToString(TotalBaseFare_return + Convert.ToDouble(lbl_fare_airporttax_return.Text) + Convert.ToDouble(lbl_fare_servicetaxfee_return.Text));

            lbl_fare_discount_return.Text = Convert.ToString(Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[1]["TDiscount"]));

            lbl_misc_return.Text = Convert.ToString(Convert.ToDouble(Session["convertor"]) * Convert.ToDouble(ds.Tables[0].Rows[1]["Other_Tax"]));
            lbl_fare_fareafterdiscount_return.Text = Convert.ToString((Convert.ToDouble(lbl_fare_fare_return.Text) + Convert.ToDouble(lbl_misc_return.Text)) - Convert.ToDouble(lbl_fare_discount_return.Text));
            lbl_fare_pg_charges_return.Text = (Convert.ToDouble(Session["convertor"]) * Convert.ToDouble("0")).ToString();
            lbl_fare_totalpayable_return.Text = Session["Currency"].ToString() + " " + Convert.ToString(lbl_fare_fareafterdiscount_return.Text);
            if (child_return > 0)
            {
                row_fare_child_return.Visible = true;
            }
            if (infant_return > 0)
            {
                row_fare_infant_return.Visible = true;
            }





          
 
        }

            //_______________________Show Arzoo Reference Id

        DataSet ds1 = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Get_ArzooRefNo", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"]))});

        lbl_Arzoo_RefNo.Text = Convert.ToString(ds1.Tables[0].Rows[0][0]);
        lbl_bookingdate.Text =         DateTime.Parse(Convert.ToString(ds1.Tables[1].Rows[0][0])).ToString("dd, MMM, yyyy");
        lbl_Arzoo_RefNo_return.Text = Convert.ToString(ds1.Tables[0].Rows[0][0]);
        lbl_bookigdate_return.Text = DateTime.Parse(Convert.ToString(ds1.Tables[1].Rows[0][0])).ToString("dd, MMM, yyyy");
            //___________________________________________
        }
     
        catch (Exception ex)
        {

            obj_AirEpointSupport.WriteToLog(ex.Message, "Ticket", "GetFlightDetails__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");
        
        }
    }

    protected void btncancel_Click(object sender, EventArgs e)
    {
     
        Session["partnerrefidtrip"]= ViewState["partnerRefId"];
        Response.Redirect("../User/Fltbookingdetails.aspx");
    }
}
   
     
 
         