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.Xml;
using System.Net.Mail;

public partial class Transaction_Cancel : System.Web.UI.Page
{
    string sys_IP;
    string Eticket = "";
    string Cancellation_details = "";
    string Cancellation_Status_request = "";
    string Cancellation_Status_request_Return = "";
    string Clientid, Clientpassword, Clienttype;
    DataSet DS_Cancellation_Request;
    DataSet DS_Cancellation_Response;
    DataSet DS_Cancellation_Status_Request;
    DataSet DS_Cancellation_Status_Request_Return;
    DataSet DS_Cancellation_Status_Response;
    DataSet DS_Cancellation_Status_Response_Return;
    decimal Total_CancellationCharges = 0;
    decimal Total_FinalRefundAmount = 0;
    DateTime Current_CancellationProcessDateTime;
    DateTime Current_RefundDateTime;
    string CancellationStatus_For_Pending_Rejected;
    int CancellationId_For_Pending_Rejected;
    decimal Total_CancellationCharges_Return = 0;
    string CancellationStatus_For_Pending_Rejected_Return;
    int CancellationId_For_Pending_Rejected_Return;
    string Current_RefundStatus;
    decimal Total_FinalRefundAmt = 0;
    string Current_Rfnd_Status;
    decimal Total_FinalRefundAmt_Return = 0;
    decimal Total_CancelationCharge = 0;
    string Current_Rfnd_Status_Return;
    string Booking_Status;
    DateTime DateTimeCurrent;
    DateTime FirstDepartDateTimeofDepartFlight;
    DateTime FirstDepartDateTimeofReturnFlight;
    DateTime DateTimeForCancellation_Validation_ForDepart_Return_Flight;
    string StatusDepart = "";
    string StatusReturn = "";
    AirEpointSupport obj_AirEpointSupport;
    string FlightType;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            obj_AirEpointSupport = new AirEpointSupport();
            sys_IP = Convert.ToString(System.Web.HttpContext.Current.Request.UserHostAddress);
            if (!IsPostBack)
            {
                if (Session["partnerrefidtransaction"] == null)
                {
                    Response.Redirect("Trip.aspx");
                }
                else
                {
                    ViewState["partnerRefId"] = Convert.ToString(Session["partnerrefidtransaction"]);

                    Session.Remove("partnerrefidtransaction");
                }
            Check_Status();
            flightinfo();
           passinfo(checkforCancellable());
            }
            if (Convert.ToString(ViewState["journeymode"]) == "Return")
            {         
            }
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Cancel", "PageLoad__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");
        }
    }
    private bool checkforCancellable()
    {
        try
        {
            int days = (Convert.ToDateTime(ViewState["departtime"]) - DateTime.Now).Days;
            if (days > 0)
            {            
                btn_cancel.Visible = true;
                return true;
            }
            else
            {
                int hours = (Convert.ToDateTime(ViewState["departtime"]) - DateTime.Now).Hours;
                if (hours > 6)
                {
                    btn_cancel.Visible = true;
                    return true;
                }
                else
                {
                    btn_cancel.Visible = true;
                    return false;
                }
            }
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Cancel", "checkforCancellable");
            return false;
        }
    }

    private bool checkforCancellable_return()
    {
        try
        {
            int days = (Convert.ToDateTime(ViewState["departtime_return"]) - DateTime.Now).Days;
            if (days > 0)
            {
                return true;
            }
            else
            {
                int hours = (Convert.ToDateTime(ViewState["departtime"]) - DateTime.Now).Hours;
                if (hours > 6)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "cancel", "CheckforCancellable_return");
            return false;
        }
    }
    private void passinfo(bool cancelable)
    {
        try
        {
            int count = 0;
            int count_return = 0;
            #region DEPART CANCEL RESPONSE         
                string CancelRequest = @"<cancellation>
<HermesPNR>" + Convert.ToString(Session["HermesPNR"]) + @"</HermesPNR>
<AirlinePNR>" + Convert.ToString(Session["PNRNoDepart"]) + @"</AirlinePNR>
<CancelStatus>0</CancelStatus>
</cancellation>";
                Hermes objhermes = new Hermes();
                DataSet ds_cancel = new DataSet();
                string cancelResponse = objhermes.Dom_Cancellation(CancelRequest);
                Session["Cancel_Details_Depart"] = cancelResponse;
                string paxno = string.Empty, firstname = string.Empty, lastname = string.Empty, pass_type = string.Empty, ticketno = string.Empty, segmentid = string.Empty, flightno = string.Empty, origin = string.Empty, departdatetime = string.Empty, destination = string.Empty, arrivaldatetime = string.Empty, classcode = string.Empty, basefare = string.Empty, totaltax = string.Empty, grossamt = string.Empty, cancelstatus = string.Empty;

                //            string abc = @"<CancellationResponse>
                //  <Status>1</Status>
                //  <AirlineID>SG</AirlineID>
                //  <HermesPNR>B6WU4O</HermesPNR>
                //  <AilinePNR>F45MMC</AilinePNR>
                //  <CRSPNR />
                //  <PassengerDetails>
                //    <item>
                //      <PaxNo>11</PaxNo>
                //      <First_Name>test</First_Name>
                //      <Last_Name>rahul</Last_Name>
                //      <PassengerType>1</PassengerType>
                //      <TicketDetails>
                //        <item>
                //          <TicketNo>B6WU4O1</TicketNo>
                //          <Segmentid>1</Segmentid>
                //          <FlightNumber>133</FlightNumber>
                //          <Origin>DEL</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //
                //        <item>
                //          <TicketNo>B6WU4O2222</TicketNo>
                //          <Segmentid>1</Segmentid>
                //          <FlightNumber>133rr</FlightNumber>
                //          <Origin>bom</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //      </TicketDetails>
                //    </item>
                //    <item>
                //      <PaxNo>12</PaxNo>
                //      <First_Name>test</First_Name>
                //      <Last_Name>alok</Last_Name>
                //      <PassengerType>1</PassengerType>
                //      <TicketDetails>
                //        <item>
                //          <TicketNo>B6WU4O2</TicketNo>
                //          <Segmentid>1</Segmentid>4
                //          <FlightNumber>133</FlightNumber>
                //          <Origin>DEL</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //      </TicketDetails>
                //    </item>
                //     <item>
                //          <TicketNo>B6WU4O1</TicketNo>
                //          <Segmentid>1</Segmentid>
                //          <FlightNumber>133</FlightNumber>
                //          <Origin>DEL</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //  </PassengerDetails>
                //<PassengerDetails>
                //    <item>
                //      <PaxNo>13</PaxNo>
                //      <First_Name>test</First_Name>
                //      <Last_Name>rahul</Last_Name>
                //      <PassengerType>1</PassengerType>
                //      <TicketDetails>
                //        <item>
                //          <TicketNo>B6WU4O1</TicketNo>
                //          <Segmentid>1</Segmentid>
                //          <FlightNumber>133</FlightNumber>
                //          <Origin>DEL</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //
                //        <item>
                //          <TicketNo>B6WU4O2222</TicketNo>
                //          <Segmentid>1</Segmentid>
                //          <FlightNumber>133rr</FlightNumber>
                //          <Origin>bom</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //      </TicketDetails>
                //    </item>
                //    <item>
                //      <PaxNo>14</PaxNo>
                //      <First_Name>test</First_Name>
                //      <Last_Name>alok</Last_Name>
                //      <PassengerType>1</PassengerType>
                //      <TicketDetails>
                //        <item>
                //          <TicketNo>B6WU4O2</TicketNo>
                //          <Segmentid>1</Segmentid>4
                //          <FlightNumber>133</FlightNumber>
                //          <Origin>DEL</Origin>
                //          <Departuredatetime>03/10/2014 07:15</Departuredatetime>
                //          <Destination>JAI</Destination>
                //          <Arrivaldatetime>03/10/2014 08:05</Arrivaldatetime>
                //          <ClassCodeDesc>T</ClassCodeDesc>
                //          <Basic_Fare>11947.00</Basic_Fare>
                //          <TotalTax>30.00</TotalTax>
                //          <GrossAmt>13156.00</GrossAmt>
                //          <CancelStatus>Live</CancelStatus>
                //        </item>
                //      </TicketDetails>
                //    </item>
                //     
                //  </PassengerDetails>
                //</CancellationResponse>";

                DataTable newTable = new DataTable();
                newTable.Columns.Add(new DataColumn("PaxNo", typeof(string)));
                newTable.Columns.Add(new DataColumn("First_Name", typeof(string)));
                newTable.Columns.Add(new DataColumn("Last_Name", typeof(string)));
                newTable.Columns.Add(new DataColumn("PassengerType", typeof(string)));
                newTable.Columns.Add(new DataColumn("TicketNo", typeof(string)));
                newTable.Columns.Add(new DataColumn("Segmentid", typeof(string)));
                newTable.Columns.Add(new DataColumn("FlightNumber", typeof(string)));
                newTable.Columns.Add(new DataColumn("Origin", typeof(string)));
                newTable.Columns.Add(new DataColumn("Departuredatetime", typeof(string)));
                newTable.Columns.Add(new DataColumn("Destination", typeof(string)));
                newTable.Columns.Add(new DataColumn("Arrivaldatetime", typeof(string)));
                newTable.Columns.Add(new DataColumn("ClassCodeDesc", typeof(string)));
                newTable.Columns.Add(new DataColumn("Basic_Fare", typeof(string)));
                newTable.Columns.Add(new DataColumn("TotalTax", typeof(string)));
                newTable.Columns.Add(new DataColumn("GrossAmt", typeof(string)));
                newTable.Columns.Add(new DataColumn("CancelStatus", typeof(string)));

                DataRow Table_Row;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(cancelResponse);
                XmlNodeList xnode = doc.ChildNodes;
                foreach (XmlNode node1 in xnode)
                {
                    XmlNodeList xnode1 = node1.ChildNodes;
                    foreach (XmlNode node2 in xnode1)
                    {
                        if (node2.Name == "PassengerDetails")
                        {
                            XmlNodeList xnode2 = node2.ChildNodes;
                            foreach (XmlNode node3 in xnode2)
                            {
                                if (node3.Name == "item")
                                {
                                    XmlNodeList xnode3 = node3.ChildNodes;
                                    foreach (XmlNode node4 in xnode3)
                                    {
                                        if (node4.Name == "PaxNo")
                                        {
                                            paxno = node4.InnerText;
                                        }
                                        if (node4.Name == "First_Name")
                                        {
                                            firstname = node4.InnerText;
                                        }
                                        if (node4.Name == "Last_Name")
                                        {
                                            lastname = node4.InnerText;
                                        }
                                        if (node4.Name == "PassengerType")
                                        {
                                            pass_type = node4.InnerText;
                                        }
                                        if (node4.Name == "TicketDetails")
                                        {
                                            XmlNodeList xnode4 = node4.ChildNodes;
                                            foreach (XmlNode node5 in xnode4)
                                            {
                                                if (node5.Name == "item")
                                                {
                                                    XmlNodeList xnode5 = node5.ChildNodes;
                                                    foreach (XmlNode node6 in xnode5)
                                                    {
                                                        if (node6.Name == "TicketNo")
                                                        {
                                                            ticketno = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Segmentid")
                                                        {
                                                            segmentid = node6.InnerText;
                                                        }
                                                        if (node6.Name == "FlightNumber")
                                                        {
                                                            flightno = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Origin")
                                                        {
                                                            origin = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Departuredatetime")
                                                        {
                                                            departdatetime = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Destination")
                                                        {
                                                            destination = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Arrivaldatetime")
                                                        {
                                                            arrivaldatetime = node6.InnerText;
                                                        }
                                                        if (node6.Name == "ClassCodeDesc")
                                                        {
                                                            classcode = node6.InnerText;
                                                        }
                                                        if (node6.Name == "Basic_Fare")
                                                        {
                                                            basefare = node6.InnerText;
                                                        }
                                                        if (node6.Name == "TotalTax")
                                                        {
                                                            totaltax = node6.InnerText;
                                                        }
                                                        if (node6.Name == "GrossAmt")
                                                        {
                                                            grossamt = node6.InnerText;
                                                        }
                                                        if (node6.Name == "CancelStatus")
                                                        {
                                                            cancelstatus = node6.InnerText;
                                                        }
                                                    }
                                                    newTable.Rows.Add(paxno, firstname, lastname, pass_type, ticketno, segmentid, flightno, origin, departdatetime, destination, arrivaldatetime, classcode, basefare, totaltax, grossamt, cancelstatus);

                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }

                Session["CancellationResponseDepart"] = newTable;
                var paxnoo = (from table1 in newTable.AsEnumerable()
                              select new { pax_no = table1.Field<string>("PaxNo") }).Distinct();
                DataTable FilterData = new DataTable();
                FilterData.Columns.Add(new DataColumn("PaxNo", typeof(string)));
                FilterData.Columns.Add(new DataColumn("First_Name", typeof(string)));
                FilterData.Columns.Add(new DataColumn("Last_Name", typeof(string)));
                FilterData.Columns.Add(new DataColumn("PassengerType", typeof(string)));
                FilterData.Columns.Add(new DataColumn("TicketNo", typeof(string)));
                foreach (var rowObj in paxnoo.ToList())
                {
                    DataTable newTable1 = (from dt2 in newTable.AsEnumerable()
                                           where dt2.Field<string>("PaxNo") == rowObj.pax_no.ToString()
                                           select dt2).CopyToDataTable();
                    paxno = newTable1.Rows[0]["PaxNo"].ToString();
                    firstname = newTable1.Rows[0]["First_Name"].ToString();
                    lastname = newTable1.Rows[0]["Last_Name"].ToString();
                    pass_type = newTable1.Rows[0]["PassengerType"].ToString();
                    ticketno = newTable1.Rows[0]["TicketNo"].ToString();
                    FilterData.Rows.Add(paxno, firstname, lastname, pass_type, ticketno);
                }

                for (int i = 1; i <= FilterData.Rows.Count; i++)
                {
                    ((HtmlTableRow)(tblpassinfo.FindControl("pass" + i.ToString()))).Visible = true;
                    ((Label)(tblpassinfo.FindControl("lbl_pass_name" + i.ToString()))).Text = FilterData.Rows[i - 1]["First_Name"].ToString() + " " + FilterData.Rows[i - 1]["Last_Name"].ToString();

                    if (FilterData.Rows[i - 1]["PassengerType"].ToString() == "1")
                    {
                        ((Label)(tblpassinfo.FindControl("lbl_pass_age" + i.ToString()))).Text = "--";
                        ((Label)(tblpassinfo.FindControl("lbl_pass_type" + i.ToString()))).Text = "Adult";
                    }
                    else if (FilterData.Rows[i - 1]["PassengerType"].ToString() == "2")
                    {
                        ((Label)(tblpassinfo.FindControl("lbl_pass_age" + i.ToString()))).Text = "--";
                        ((Label)(tblpassinfo.FindControl("lbl_pass_type" + i.ToString()))).Text = "Child";
                    }
                    else
                    {
                        ((Label)(tblpassinfo.FindControl("lbl_pass_age" + i.ToString()))).Text = "--";
                        ((Label)(tblpassinfo.FindControl("lbl_pass_type" + i.ToString()))).Text = "Infant";
                    }
                    //else
                    //{
                    //    ((Label)(tblpassinfo.FindControl("lbl_pass_age" + i.ToString()))).Text = ds.Tables[0].Rows[i - 1]["Age"].ToString();
                    //}



                    // if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Processed")
                    // {
                    //     ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Text = "Refunded";
                    //     ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Visible = true;
                    ////     ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString()))).Visible = false;
                    //     ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Visible = false;
                    //     ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Checked = false;

                    // }
                    // else if (ds.Tables[0].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
                    // {
                    //     ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Text = "Cancellation Under Process";
                    //     ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Visible = true;
                    //   //  ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Visible = false;
                    //     //((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString()))).Visible = true;
                    //   //  ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString()))).Text = "Cancellation Under Process";
                    //  //   ((Label)(tblpassinfo.FindControl("lbl_canid" + i.ToString()))).Text = Convert.ToString(ds.Tables[0].Rows[i - 1]["CancellationId"]);

                    //     ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Visible = false;
                    //     ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Checked = false;

                    // }
                    ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Visible = true;
                    //      ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString()))).Visible = false;
                    ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString()))).Text = FilterData.Rows[i - 1]["TicketNo"].ToString();
                    ((Label)(tblpassinfo.FindControl("paxid" + i.ToString()))).Text = FilterData.Rows[i - 1]["paxno"].ToString();
                    ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Visible = true;
                    ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Checked = false;
                    count++;
                    if (!cancelable)
                    {
                        ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Visible = true;
                        ((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Checked = false;
                    }
                }

                //if (count > 0) btn_cancel.Visible = true;
                //else
                //    btn_cancel.Visible = false;
           
            #endregion

                #region DEPART CANCEL RESPONSE
                if (ViewState["journeymode"] == "Return")
                {
                    string CancelRequestret = @"<cancellation>
<HermesPNR>" + Convert.ToString(Session["HermesPNRReturn"]) + @"</HermesPNR>
<AirlinePNR>" + Convert.ToString(Session["PNRNoReturn"]) + @"</AirlinePNR>
<CancelStatus>0</CancelStatus>
</cancellation>";
                    DataSet ds_cancelreturn = new DataSet();
                    string cancelResponsereturn = objhermes.Dom_Cancellation(CancelRequestret);
                    Session["Cancel_Details_Return"] = cancelResponsereturn;
                    string paxnoReturn = string.Empty, firstnameReturn = string.Empty, lastnameReturn = string.Empty, pass_typeReturn = string.Empty, ticketnoReturn = string.Empty, segmentidReturn = string.Empty, flightnoReturn = string.Empty, originReturn = string.Empty, departdatetimeReturn = string.Empty, destinationReturn = string.Empty, arrivaldatetimeReturn = string.Empty, classcodeReturn = string.Empty, basefareReturn = string.Empty, totaltaxReturn = string.Empty, grossamtReturn = string.Empty, cancelstatusReturn = string.Empty;
                    DataTable newTableReturn = new DataTable();
                    newTableReturn.Columns.Add(new DataColumn("PaxNo", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("First_Name", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Last_Name", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("PassengerType", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("TicketNo", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Segmentid", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("FlightNumber", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Origin", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Departuredatetime", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Destination", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Arrivaldatetime", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("ClassCodeDesc", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("Basic_Fare", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("TotalTax", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("GrossAmt", typeof(string)));
                    newTableReturn.Columns.Add(new DataColumn("CancelStatus", typeof(string)));

                    DataRow Table_RowReturn;
                    XmlDocument docx = new XmlDocument();
                    docx.LoadXml(cancelResponsereturn);
                    XmlNodeList xnodereturn = docx.ChildNodes;
                    foreach (XmlNode node1 in xnodereturn)
                    {
                        XmlNodeList xnode1 = node1.ChildNodes;
                        foreach (XmlNode node2 in xnode1)
                        {
                            if (node2.Name == "PassengerDetails")
                            {
                                XmlNodeList xnode2 = node2.ChildNodes;
                                foreach (XmlNode node3 in xnode2)
                                {
                                    if (node3.Name == "item")
                                    {
                                        XmlNodeList xnode3 = node3.ChildNodes;
                                        foreach (XmlNode node4 in xnode3)
                                        {
                                            if (node4.Name == "PaxNo")
                                            {
                                                paxnoReturn = node4.InnerText;
                                            }
                                            if (node4.Name == "First_Name")
                                            {
                                                firstnameReturn = node4.InnerText;
                                            }
                                            if (node4.Name == "Last_Name")
                                            {
                                                lastnameReturn = node4.InnerText;
                                            }
                                            if (node4.Name == "PassengerType")
                                            {
                                                pass_typeReturn = node4.InnerText;
                                            }
                                            if (node4.Name == "TicketDetails")
                                            {
                                                XmlNodeList xnode4 = node4.ChildNodes;
                                                foreach (XmlNode node5 in xnode4)
                                                {
                                                    if (node5.Name == "item")
                                                    {
                                                        XmlNodeList xnode5 = node5.ChildNodes;
                                                        foreach (XmlNode node6 in xnode5)
                                                        {
                                                            if (node6.Name == "TicketNo")
                                                            {
                                                                ticketnoReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Segmentid")
                                                            {
                                                                segmentidReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "FlightNumber")
                                                            {
                                                                flightnoReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Origin")
                                                            {
                                                                originReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Departuredatetime")
                                                            {
                                                                departdatetimeReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Destination")
                                                            {
                                                                destinationReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Arrivaldatetime")
                                                            {
                                                                arrivaldatetimeReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "ClassCodeDesc")
                                                            {
                                                                classcodeReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "Basic_Fare")
                                                            {
                                                                basefareReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "TotalTax")
                                                            {
                                                                totaltaxReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "GrossAmt")
                                                            {
                                                                grossamtReturn = node6.InnerText;
                                                            }
                                                            if (node6.Name == "CancelStatus")
                                                            {
                                                                cancelstatusReturn = node6.InnerText;
                                                            }

                                                        }
                                                        newTableReturn.Rows.Add(paxnoReturn, firstnameReturn, lastnameReturn, pass_typeReturn, ticketnoReturn, segmentidReturn, flightnoReturn, originReturn, departdatetimeReturn, destinationReturn, arrivaldatetimeReturn, classcodeReturn, basefareReturn, totaltaxReturn, grossamtReturn, cancelstatusReturn);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }

                    Session["CancellationResponseReturn"] = newTableReturn;
                    var paxnumber = (from table1 in newTableReturn.AsEnumerable()
                                     select new { pax_no_return = table1.Field<string>("PaxNo") }).Distinct();
                    DataTable FilterData_return = new DataTable();
                    FilterData_return.Columns.Add(new DataColumn("PaxNo", typeof(string)));
                    FilterData_return.Columns.Add(new DataColumn("First_Name", typeof(string)));
                    FilterData_return.Columns.Add(new DataColumn("Last_Name", typeof(string)));
                    FilterData_return.Columns.Add(new DataColumn("PassengerType", typeof(string)));
                    FilterData_return.Columns.Add(new DataColumn("TicketNo", typeof(string)));
                    foreach (var rowObj in paxnumber.ToList())
                    {
                        DataTable newTable1 = (from dt2 in newTable.AsEnumerable()
                                               where dt2.Field<string>("PaxNo") == rowObj.pax_no_return.ToString()
                                               select dt2).CopyToDataTable();
                        paxnoReturn = newTable1.Rows[0]["PaxNo"].ToString();
                        firstnameReturn = newTable1.Rows[0]["First_Name"].ToString();
                        lastnameReturn = newTable1.Rows[0]["Last_Name"].ToString();
                        pass_typeReturn = newTable1.Rows[0]["PassengerType"].ToString();
                        ticketnoReturn = newTable1.Rows[0]["TicketNo"].ToString();
                        FilterData_return.Rows.Add(paxnoReturn, firstnameReturn, lastnameReturn, pass_typeReturn, ticketnoReturn);
                    }

                    for (int i = 1; i <= FilterData_return.Rows.Count; i++)
                    {
                        ((HtmlTableRow)(tblpassinfo_return.FindControl("pass" + i.ToString() + "_return"))).Visible = true;
                        ((Label)(tblpassinfo_return.FindControl("lbl_pass_name" + i.ToString() + "_return"))).Text = FilterData_return.Rows[i - 1]["First_Name"].ToString() + " " + FilterData_return.Rows[i - 1]["Last_Name"].ToString();

                        if (FilterData_return.Rows[i - 1]["PassengerType"].ToString() == "1")
                        {
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_age" + i.ToString() + "_return"))).Text = "--";
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_type" + i.ToString() + "_return"))).Text = "Adult";
                        }
                        else if (FilterData_return.Rows[i - 1]["PassengerType"].ToString() == "2")
                        {
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_age" + i.ToString() + "_return"))).Text = "--";
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_type" + i.ToString() + "_return"))).Text = "Child";
                        }
                        else
                        {
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_age" + i.ToString() + "_return"))).Text = "--";
                            ((Label)(tblpassinfo_return.FindControl("lbl_pass_type" + i.ToString() + "_return"))).Text = "Infant";
                        }
                        ((Label)(tblpassinfo_return.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Visible = true;
                        ((Label)(tblpassinfo_return.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Text = FilterData_return.Rows[i - 1]["TicketNo"].ToString();
                        ((Label)(tblpassinfo_return.FindControl("paxid" + i.ToString() + "_return"))).Text = FilterData_return.Rows[i - 1]["paxno"].ToString();
                        ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = true;
                        ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;
                        count++;
                        if (!cancelable)
                        {
                            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = true;
                            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;
                        }
                    }
                }
                #endregion
            //_______________________________

            //if (ViewState["journeymode"] == "Return")
            //{

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

            //        //int count = (from a in previouspassuid
            //        //             where a == ds.Tables[0].Rows[i - 1]["Passuid"].ToString()
            //        //             select a).Count();

            //        //if (count == 0)
            //        //{
            //        //    previouspassuid[temp++] = ds.Tables[0].Rows[i - 1]["Passuid"].ToString();


            //        ((HtmlTableRow)(tblpassinfo_return.FindControl("pass" + i.ToString() + "_return"))).Visible = true;
            //        ((Label)(tblpassinfo_return.FindControl("lbl_pass_name" + i.ToString() + "_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_age" + i.ToString() + "_return"))).Text = "--";
            //        }
            //        else
            //        {
            //            ((Label)(tblpassinfo_return.FindControl("lbl_pass_age" + i.ToString() + "_return"))).Text = ds.Tables[1].Rows[i - 1]["Age"].ToString();
            //        }
            //        ((Label)(tblpassinfo_return.FindControl("lbl_pass_type" + i.ToString() + "_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_passe_ticket" + i.ToString() + "_return"))).Text = "Refunded";
            //            ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Visible = true;
            //   //         ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString() + "_return"))).Visible = false;
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = false;
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;

            //        }
            //        else if (ds.Tables[1].Rows[i - 1]["CancellationStatus"].ToString() == "Pending")
            //        {
            //      //      ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString() + "_return"))).Visible = true;
            //        //    ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString() + "_return"))).Text = "Cancellation Under Process";
            //            ((Label)(tblpassinfo_return.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Text = "Cancellation Under Process";
            //            ((Label)(tblpassinfo_return.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Visible = true;
            //          //  ((Label)(tblpassinfo.FindControl("lbl_canid" + i.ToString() + "_return"))).Text = Convert.ToString(ds.Tables[1].Rows[i - 1]["CancellationId"]);
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = false;
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;

            //        }
            //        else
            //        {
            //            ((Label)(tblpassinfo.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Visible = true;
            //      //      ((LinkButton)(tblpassinfo.FindControl("link_pass" + i.ToString() + "_return"))).Visible = false;
            //            ((Label)(tblpassinfo_return.FindControl("lbl_passe_ticket" + i.ToString() + "_return"))).Text = ViewState["pnrnumber_return"].ToString();  // ds.Tables[0].Rows[i - 1]["eticketno"].ToString();
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = true;
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;
            //            count_return++;
            //        }

            //        if (!cancelable_return)
            //        {
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Visible = false;
            //            ((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked = false;
            //        }


            //    }
            //    if (count_return > 0) btn_cancel_return.Visible = true;
            //    else
            //        btn_cancel_return.Visible = false;

            //}

            }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "cancel", "Passinfo__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");
        }
    }
    private void Check_Status()
    {
        try
        {
            SqlParameter[] paramBookingInformation = new SqlParameter[]
            {
                 new SqlParameter("@ResultBkngInf_Output",SqlDbType.Int,4),
                 new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),

                   new SqlParameter("@userid",Convert.ToString(Session["agid"])),             
            };
            paramBookingInformation[0].Direction = ParameterDirection.Output;
            DataSet DataSetBookingInformationStatus = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Air_GetBookingInformationStatus", paramBookingInformation);
            string ResultBkngInf = Convert.ToString(paramBookingInformation[0].Value);
            if (ResultBkngInf == "1")
            {
                string Status = Convert.ToString(DataSetBookingInformationStatus.Tables[0].Rows[0]["Status"]);
                if (DataSetBookingInformationStatus.Tables[0].Rows.Count > 1)
                {
                    string StatusReturn = Convert.ToString(DataSetBookingInformationStatus.Tables[0].Rows[1]["Status"]);
                    ViewState["TicketStatusReturn"] = StatusReturn;
                    ViewState["TicketStatus"] = Status;
                }
                else
                {
                    ViewState["TicketStatus"] = Status;
                    ViewState["TicketStatusReturn"] = Status;
                }
                if (Status == "Pending")
               {
                    //    Response.Redirect("Trip.aspx");

                }
                else if (Status == "SUCCESS" || Status == "Refunded")
                {
                    ViewState["transid"] = Convert.ToString(DataSetBookingInformationStatus.Tables[0].Rows[0]["transid"]); 
                    if (DataSetBookingInformationStatus.Tables[0].Rows.Count > 1)
                    {
                        ViewState["transidReturn"] = Convert.ToString(DataSetBookingInformationStatus.Tables[0].Rows[1]["transid"]);
                    }                   
                    Session["HermesPNR"] = Convert.ToString(ViewState["transid"]);
                    Session["HermesPNRReturn"] = Convert.ToString(ViewState["transidReturn"]);                   
                }
                else if (Status == "Cancelled")
                {
                      Response.Redirect("Trip.aspx",false);
                }
            }
            else if (ResultBkngInf == "0")
            {
                // "BookingInformation Status not Get successfully"; Technical Error Occured
            }
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "cancel", "Check Status__" + 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) });
            Session["FlightDetails"] = ds;
            if (ds.Tables[1].Rows.Count > 0)
            {
                ViewState["journeymode"] = "Return";
                Session["journeymode"] = "Return";
            }
            else
            {
                ViewState["journeymode"] = "Depart";
                Session["journeymode"] = "Depart";
            }

            ViewState["departtime"] = ds.Tables[0].Rows[0]["DepartureDateTime"];
            ViewState["pnrnumber"] = Convert.ToString(ds.Tables[0].Rows[0]["pnrnumber"]);
            Session["PNRNoDepart"] = ViewState["pnrnumber"];
            ViewState["flightdatalavi"] = ds.Tables[0].Rows[0]["OperatingAirlineCode"] + "-" + ds.Tables[0].Rows[0]["FlightNumber"];
            ViewState["airlinenamelavi"] = ds.Tables[0].Rows[0]["airLineName"].ToString();
            ViewState["arrivaltimelavi"] = ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["ArrivalDateTime"];
            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=\"border:1px solid #000;padding:5px\">";
            data += "    Airline   </td>";
            data += "    <td width=\"12%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Flight Number   </td>";
            data += "     <td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">    Departure Details </td>";
            data += "<td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Arrival Details </td>";
            data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Ticket PNR    </td>";
            data += "  </tr>";
            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=\"border:1px solid #000;padding:5px\">";
                if (FlightType == "DOM")
                {
                    data += ds.Tables[0].Rows[i]["airLineName"].ToString() + "   </td>";
                }
                else if (FlightType == "INAIR")
                {
                    data += ds.Tables[0].Rows[i]["OperatingAirLineName"].ToString() + "   </td>";
                }
                data += "<td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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=\"border:1px solid #000;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=\"border:1px solid #000;padding:5px\">";
                data += Convert.ToString(ds.Tables[0].Rows[i]["Confirmationid"]);
                data += " </td>";
                data += "  </tr>";
            }
            data += " </table>";
            literal_flightinfo.Text = data;
            //______________________________________________________________________________________________________________________________
            flightdetails_return.Visible = false;
            flightdetails_flightinfo_return.Visible = false;
            passengerdetail_return.Visible = false;
            passengerdetails_return.Visible = false;
           // btns_return.Visible = false;
            if (ViewState["journeymode"] == "Return")
            {
                flightdetails_return.Visible = true;
                flightdetails_flightinfo_return.Visible = true;
                passengerdetail_return.Visible = true;
                passengerdetails_return.Visible = true;
                //btns_return.Visible = true;
                ViewState["departtime_return"] = ds.Tables[1].Rows[0]["DepartureDateTime"];
                ViewState["pnrnumber_return"] = Convert.ToString(ds.Tables[1].Rows[0]["pnrnumber"]);
                Session["PNRNoReturn"] = ViewState["pnrnumber_return"];
                ViewState["flightdatalavi_return"] = ds.Tables[1].Rows[0]["OperatingAirlineCode"] + "-" + ds.Tables[1].Rows[0]["FlightNumber"];
                ViewState["airlinenamelavi_return"] = ds.Tables[1].Rows[0]["airLineName"].ToString();
                ViewState["arrivaltimelavi_return"] = ds.Tables[1].Rows[ds.Tables[1].Rows.Count - 1]["ArrivalDateTime"];
                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:1px solid #000;padding:5px\">";
                data += "    Airline   </td>";
                data += "    <td width=\"12%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Flight Number   </td>";
                data += "     <td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">    Departure Details </td>";
                data += "<td colspan=\"3\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Arrival Details </td>";
                data += "<td width=\"14%\" align=\"center\" valign=\"middle\" class=\"txt2\" style=\"border:1px solid #000;padding:5px\">   Ticket PNR    </td>";
                data += "  </tr>";
                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:1px solid #000;padding:5px\">";
                    data += ds.Tables[1].Rows[i]["airLineName"].ToString() + "   </td>";
                    data += "<td width=\"12%\" height=\"20\" align=\"center\" valign=\"middle\" class=\"txt1\" style=\"border:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;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:1px solid #000;padding:5px\">";
                    data += Convert.ToString(ds.Tables[1].Rows[i]["Confirmationid"]);
                    data += " </td>";
                    data += "  </tr>";
                }
                data += " </table>";
                literal_flightinfo_return.Text = data;
            }
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "cancel", "flight info__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");
        }
    }
    //public void Get_Cancellation_Request_Response()
    //{
    //    FlightType = obj_AirEpointSupport.getFlightType(Convert.ToString(ViewState["partnerRefId"]),Convert.ToString(Session["HURL"]));
    //    try
    //    {
    //        string booking_status1 = "";
    //        string cdate = DateTime.Now.ToString("yyy-MM-dd");
    //        string ctime = DateTime.Now.ToString("HH_mm_ss");
    //        string time_date = cdate + "_" + ctime;
    //        #region Send_Cancellation_Request_And_Get_Cancellation_Response
    //        if (Convert.ToString(ViewState["TicketStatus"]) == "SUCCESS" || Convert.ToString(ViewState["TicketStatus"]) == "Cancelled" || Convert.ToString(ViewState["TicketStatus"]) == "Refunded")
    //        {
    //            if (Convert.ToString(ViewState["TicketStatus"]) == "SUCCESS" || Convert.ToString(ViewState["TicketStatus"]) == "Refunded")
    //            {
    //                booking_status1 = "Successtkd";
    //            }
    //            else if (Convert.ToString(ViewState["TicketStatus"]) == "Cancelled")
    //            {
    //                booking_status1 = "SUCCESSCan";
    //            }
    //            if (FlightType == "DOM")
    //            {
    //                Cancellation_details = "<CancelationDetails><Clientid>" + Clientid + "</Clientid><Clientpassword>" + Clientpassword + "</Clientpassword><Clienttype>" + Clienttype + "</Clienttype><transid>" + Convert.ToString(ViewState["transid"]) + "</transid><status>" + booking_status1 + "</status><remarks>Cancellation Request</remarks>" + Convert.ToString(ViewState["eticketdto"]) + "</CancelationDetails>";
    //            }
    //            else if (FlightType == "INAIR")
    //            {
                       
    //                Cancellation_details = "<CanIntRequest><Clientid>" + IntClientID + "</Clientid><Clientpassword>" + IntClientPassword + "</Clientpassword><Clienttype>" + IntClientType + "</Clienttype><Transid>" + Convert.ToString(ViewState["transid"]) + "</Transid><Remarks>Cancellation Request</Remarks>" + Convert.ToString(ViewState["eticketdto"]) + "</CanIntRequest>";
               
    //            }
    //            DS_Cancellation_Request = new DataSet();
    //            DS_Cancellation_Request.ReadXml(new StringReader(Convert.ToString(Cancellation_details)));
    
    //            string Get_cancellationDetails = "";
    //            if (FlightType == "DOM")
    //            {
    //                obj_AirEpointSupport.WriteXmlLog(Cancellation_details, "Domestic_Cancellation_Request__" + Convert.ToString(ViewState["partnerRefId"]));

               
 


    //                DOMFlightCancellation domfc = new DOMFlightCancellation();
    //                Get_cancellationDetails = domfc.getCancelation(Convert.ToString(Cancellation_details));
    //                obj_AirEpointSupport.WriteXmlLog(Get_cancellationDetails, "Domestic_Cancellation_Response__" + Convert.ToString(ViewState["partnerRefId"]));
    //                ViewState["Get_cancellationDetails"] = Get_cancellationDetails;
    //            }
    //            else if (FlightType == "INAIR")
    //            {
    //                Get_cancellationDetails = obj_AirEpointSupport.sendRequestAndGetResponse_Arzoo(IntCancellation, Cancellation_details);
    //                ViewState["Get_cancellationDetails"] = Get_cancellationDetails;
    //            }
    //            DS_Cancellation_Response = new DataSet();
    //            DS_Cancellation_Response.ReadXml(new StringReader(Convert.ToString(Get_cancellationDetails)));
    //            //   DS_Cancellation_Response.WriteXml(Convert.ToString(Session["folderpath"]) + "/" + Convert.ToString(ViewState["partnerRefId"]) + "_Cancellation_Response" + time_date + ".xml");

    //        }


    //        #endregion
    //    }

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

    //    }

    //}
    //send canclation status request
    //public void Get_Cancellation_Status_Request_Response()
    //{
    //    try
    //    {
    //        string cdate = DateTime.Now.ToString("yyy-MM-dd");
    //        string ctime = DateTime.Now.ToString("HH_mm_ss");
    //        string time_date = cdate + "_" + ctime;
    //        #region Send Cancellation Status Request and Get Cancellation Status Response xml

    //        if (Convert.ToString(ViewState["Cancellation_Response_error"]) != "")
    //        {
    //            ViewState["Cancellation_id"] = "";

    //        }


    //        Cancellation_Status_request = "<EticketCanStatusReq><Clientid>" + Clientid + "</Clientid><Clientpassword>" + Clientpassword + "</Clientpassword><Clienttype>" + Clienttype + "</Clienttype><transid>" + Convert.ToString(ViewState["transid"]) + "</transid><partnerRefId>" + Convert.ToString(ViewState["partnerRefId"]) + "</partnerRefId><CancellationId>" + Convert.ToString(ViewState["Cancellation_id"]) + "</CancellationId></EticketCanStatusReq>";
    //        obj_AirEpointSupport.WriteXmlLog(Cancellation_Status_request, "Domestic_CancellationStatus_Request__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Request = new DataSet();
    //        DS_Cancellation_Status_Request.ReadXml(new StringReader(Convert.ToString(Cancellation_Status_request)));
    




    //        DOMFlightCancellationStatus domfs = new DOMFlightCancellationStatus();
    //        string Get_Cancellation_Status = domfs.getCancelationStatus(Convert.ToString(Cancellation_Status_request));
    //        obj_AirEpointSupport.WriteXmlLog(Get_Cancellation_Status, "Domestic_CancellationStatus_Response__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Response = new DataSet();
    //        DS_Cancellation_Status_Response.ReadXml(new StringReader(Convert.ToString(Get_Cancellation_Status)));
 

    //        #endregion
    //    }

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

    //    }



    //}
    //send canclation status request for return
    //public void Get_Cancellation_Status_Request_Response_Return()
    //{
    //    try
    //    {
    //        string cdate = DateTime.Now.ToString("yyy-MM-dd");
    //        string ctime = DateTime.Now.ToString("HH_mm_ss");
    //        string time_date = cdate + "_" + ctime;
    //        #region Send Cancellation Status Request and Get Cancellation Status Response xml

    //        if (Convert.ToString(ViewState["Cancellation_Response_error"]) != "")
    //        {
    //            ViewState["Cancellation_id_Return"] = "";

    //        }


    //        Cancellation_Status_request_Return = "<EticketCanStatusReq><Clientid>" + Clientid + "</Clientid><Clientpassword>" + Clientpassword + "</Clientpassword><Clienttype>" + Clienttype + "</Clienttype><transid>" + Convert.ToString(ViewState["transid"]) + "</transid><partnerRefId>" + Convert.ToString(ViewState["partnerRefId"]) + "</partnerRefId><CancellationId>" + Convert.ToString(ViewState["Cancellation_id_Return"]) + "</CancellationId></EticketCanStatusReq>";
    //        DS_Cancellation_Status_Request_Return = new DataSet();
    //        DS_Cancellation_Status_Request_Return.ReadXml(new StringReader(Convert.ToString(Cancellation_Status_request_Return)));
 



    //        obj_AirEpointSupport.WriteXmlLog(Cancellation_Status_request_Return, "Domestic_CancellationStatus_Request_Return__" + Convert.ToString(ViewState["partnerRefId"]));

    //        DOMFlightCancellationStatus domfs = new DOMFlightCancellationStatus();
    //        string Get_Cancellation_Status_Response = domfs.getCancelationStatus(Convert.ToString(Cancellation_Status_request_Return));
    //        obj_AirEpointSupport.WriteXmlLog(Get_Cancellation_Status_Response, "Domestic_CancellationStatus_Response_Return__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Response_Return = new DataSet();
    //        DS_Cancellation_Status_Response_Return.ReadXml(new StringReader(Convert.ToString(Get_Cancellation_Status_Response)));
 






    //        #endregion
    //    }

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



    //}
    public void Get_Cancellation_Status_Response_For_UpdateTable()
    {
        try
        {

            #region Get Cancellation_Status_Response and Display Cancel and Refund Amount details
            if ((!DS_Cancellation_Status_Response.Tables["EticketCanStatusRes"].Columns.Contains("error")))
            {
                if (DS_Cancellation_Status_Response.Tables.Contains("Cancellation"))
                {
                    if (DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count != 0)
                    {


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

                 
                            if ((DS_Cancellation_Status_Response.Tables["Cancellation"].Columns.Contains("CancellationStatus")))
                            {
                                ViewState["Cancellation_status_response"] = Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationStatus"]);


                                if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Pending")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation is under process.')</script>");


                                }
                                else if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Processed")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation is done.')</script>");



                                }

                                else if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Rejected")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation request is rejected.')</script>");


                                }


                            }

                            if ((DS_Cancellation_Status_Response.Tables["Cancellation"].Columns.Contains("RefundStatus")))
                            {

                                ViewState["Refund_status_response"] = Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundStatus"]);


                                if (Convert.ToString(ViewState["Refund_status_response"]) == "Pending")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Refund is under process.')</script>");


                                }

                                else if (Convert.ToString(ViewState["Refund_status_response"]) == "Processed")
                                {
                                    Page.RegisterStartupScript("XXX", "<script> alert('Refund is successfully done.')</script>");



                                }

                            }

                        }



                    }


                }


            }
            else
            {

                string EticketStatus_response_Error = Convert.ToString(DS_Cancellation_Status_Response.Tables["EticketCanStatusRes"].Rows[0]["error"]);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('" + EticketStatus_response_Error + "');", true);
            }

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

        }
    }
    public void Get_Cancellation_Status_Response_For_UpdateTable_ReturnFlight()
    {
        try
        {

            #region Get Cancellation_Status_Response of Return Flight and Display Cancel and Refund Amount details
            if ((!DS_Cancellation_Status_Response_Return.Tables["EticketCanStatusRes"].Columns.Contains("error")))
            {
                if (DS_Cancellation_Status_Response_Return.Tables.Contains("Cancellation"))
                {
                    if (DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count != 0)
                    {


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

                  
                            if ((DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Columns.Contains("CancellationStatus")))
                            {
                                ViewState["Cancellation_status_response_Return"] = Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationStatus"]);


                                if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Pending")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation is under process.')</script>");


                                }
                                else if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Processed")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation is done.')</script>");



                                }

                                else if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Rejected")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Ticket (s) cancellation request is rejected.')</script>");


                                }


                            }

                            if ((DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Columns.Contains("RefundStatus")))
                            {

                                ViewState["Refund_status_response_Return"] = Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundStatus"]);


                                if (Convert.ToString(ViewState["Refund_status_response_Return"]) == "Pending")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Refund is under process.')</script>");


                                }

                                else if (Convert.ToString(ViewState["Refund_status_response_Return"]) == "Processed")
                                {

                                    Page.RegisterStartupScript("XXX", "<script> alert('Refund is successfully done.')</script>");



                                }

                            }

                        }



                    }


                }


            }
            else
            {

                string EticketStatus_response_Error_Return = Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["EticketCanStatusRes"].Rows[0]["error"]);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('" + EticketStatus_response_Error_Return + "');", true);
            }

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

        }
    }
    public void Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_DepartFlight()
    {
        string Result_param_Cancellatin_Status_Response_Pending = "";

        try
        {
            //if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Pending")
            //{


            //    if (DS_Cancellation_Response.Tables.Contains("onwardcanceldata"))
            //    {

            //        if (DS_Cancellation_Response.Tables["onwardcanceldata"].Rows.Count != 0)
            //        {

            //            XmlDocument xDoc = new XmlDocument();
            //            xDoc.LoadXml(Convert.ToString(ViewState["Get_cancellationDetails"]));


            //            XmlNodeList xmlNodes = xDoc.GetElementsByTagName("onwardcanceldata");

            //            foreach (XmlNode xNode in xmlNodes)
            //            {
            //                XmlNodeList innerNodeList = xNode.ChildNodes;
            //                foreach (XmlNode xNodeInner in innerNodeList)
            //                {
            //                    string Canid = xNode["Canid"].InnerText;
            //                    string Cancellation_status = xNode["status"].InnerText;


            //if (xNodeInner.Name == "eticketdto")
            //{

            //    string Cancel_EticketData = xNodeInner.OuterXml;

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

                 Session["FlightInfoDepart"] = ds_Cancel_Eticket_pending;

                 int Canid = Convert.ToInt32(Session["canid"]);
                 string Cancellation_status = Convert.ToString(Session["CancellationStatusDepart"]);
                #region Insert Adult child ,infant ticket info when status response pending
                for (int i = 0; i < ds_Cancel_Eticket_pending.Tables[0].Rows.Count; i++)
                {
                   
               
                    SqlParameter[] param_Cancellation_Details_Pending = new SqlParameter[]
                                   {

                             new SqlParameter("@Result_Adult_Child_Infant_TicketInfo_Output",SqlDbType.Int,4),
                             new SqlParameter("@Booking_St_Id",Convert.ToString(ds_Cancel_Eticket_pending.Tables[0].Rows[i]["Booking_ST_Id"])),
                             new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                             new SqlParameter("@CancellationId",Convert.ToInt32(Canid)),
                             new SqlParameter("@CancellationStatus",Cancellation_status),
                             new SqlParameter("@eticketno",Convert.ToString(ds_Cancel_Eticket_pending.Tables[0].Rows[i]["eticketno"])), 
                             new SqlParameter("@flightuid",Convert.ToString(ds_Cancel_Eticket_pending.Tables[0].Rows[i]["flightuid"])),
                             new SqlParameter("@passuid",Convert.ToString(ds_Cancel_Eticket_pending.Tables[0].Rows[i]["passuid"])),
                             new SqlParameter("@JourneyType","Depart"),
                       
                                    
                                   };



                    param_Cancellation_Details_Pending[0].Direction = ParameterDirection.Output;

                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Air_Insert_Adult_child_infant_Cancellation_details_for_Status_Response_pending", param_Cancellation_Details_Pending);

                    Result_param_Cancellatin_Status_Response_Pending = Convert.ToString(param_Cancellation_Details_Pending[0].Value);

                }


                if (Result_param_Cancellatin_Status_Response_Pending == "1")
                {
                    Insert_Air_Cancellation_Details_Table_When_Status_Pending();

                }
                else if (Result_param_Cancellatin_Status_Response_Pending == "0")
                {
                    //     //lblerrormsg.Text = "Cancellation Details of Adult,child,infant For Depart flight o for cancellation status response pending not update successfully";
                }

                #endregion

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

    }
    public void Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight()
    {
        string Result_param_Cancellatin_Status_Response_Pending_Return = "";

        try
        {
            //if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Pending")
            //{


            //    if (DS_Cancellation_Response.Tables.Contains("returncanceldata"))
            //    {

            //        if (DS_Cancellation_Response.Tables["returncanceldata"].Rows.Count != 0)
            //        {

            //            XmlDocument xDoc = new XmlDocument();
            //            xDoc.LoadXml(Convert.ToString(ViewState["Get_cancellationDetails"]));


            //            XmlNodeList xmlNodes = xDoc.GetElementsByTagName("returncanceldata");

            //            foreach (XmlNode xNode in xmlNodes)
            //            {
            //                XmlNodeList innerNodeList = xNode.ChildNodes;
            //                foreach (XmlNode xNodeInner in innerNodeList)
            //                {
            //                    string Canid = xNode["Canid"].InnerText;
            //                    string Cancellation_status = xNode["status"].InnerText;


            //                    if (xNodeInner.Name == "eticketdto")
            //                    {

                                   // string Cancel_EticketData_return = xNodeInner.OuterXml;


                                 DataSet ds_Cancel_Eticket_pending_Return = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_get_pass_info", new SqlParameter[] { new SqlParameter("@partnerrefid", Convert.ToString(ViewState["partnerRefId"])) });
                                  //  DataSet ds_Cancel_Eticket_pending_Return = new DataSet();
                                   // ds_Cancel_Eticket_pending_Return.ReadXml(new StringReader(Cancel_EticketData_return));
                                 Session["FlightInfoReturn"] = ds_Cancel_Eticket_pending_Return;
                                 int Canid = Convert.ToInt32(Session["canid"]);
                                 string Cancellation_status = Convert.ToString(Session["CancellationStatusReturn"]);

                                    #region Insert Adult child ,infant ticket info when status response pending
                                    for (int i = 0; i < ds_Cancel_Eticket_pending_Return.Tables[1].Rows.Count; i++)
                                    {
                                      
                                        SqlParameter[] param_Cancellation_Details_Pending_Return = new SqlParameter[]
                                   {

                             new SqlParameter("@Result_Adult_Child_Infant_TicketInfo_Output",SqlDbType.Int,4),
                             new SqlParameter("@Booking_St_Id",Convert.ToString(ds_Cancel_Eticket_pending_Return.Tables[1].Rows[i]["Booking_ST_Id"])),
                             new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                             new SqlParameter("@CancellationId",Convert.ToInt32(Canid)),
                             new SqlParameter("@CancellationStatus",Cancellation_status),
                             new SqlParameter("@eticketno",Convert.ToString(ds_Cancel_Eticket_pending_Return.Tables[1].Rows[i]["eticketno"])), 
                             new SqlParameter("@flightuid",Convert.ToString(ds_Cancel_Eticket_pending_Return.Tables[1].Rows[i]["flightuid"])),
                             new SqlParameter("@passuid",Convert.ToString(ds_Cancel_Eticket_pending_Return.Tables[1].Rows[i]["passuid"])),
                             new SqlParameter("@JourneyType","Return"),
                                                         
                                   };
                                        param_Cancellation_Details_Pending_Return[0].Direction = ParameterDirection.Output;

                                        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Air_Insert_Adult_child_infant_Cancellation_details_for_Status_Response_pending", param_Cancellation_Details_Pending_Return);

                                        Result_param_Cancellatin_Status_Response_Pending_Return = Convert.ToString(param_Cancellation_Details_Pending_Return[0].Value);

                                    }


                                    if (Result_param_Cancellatin_Status_Response_Pending_Return == "1")
                                    {

                                        Insert_Air_Cancellation_Details_Table_When_Status_Pending_For_ReturnFlight();
                                    }
                                    else if (Result_param_Cancellatin_Status_Response_Pending_Return == "0")
                                    {
                                        //     //lblerrormsg.Text = "Cancellation Details of Adult,child,infant For Return flight o for cancellation status response pending not update successfully";
                                    }

                                    #endregion

        }
        catch (Exception ex)
        {

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

        }





    }
    public void Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response()
    {
        try
        {
            if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Processed")
            {

                if (DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count != 0)
                {


                    for (int i = 0; i < DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count; i++)
                    {
                        #region Update_Cancellation and Refund Details in Adult_Child_Infant_TicketInfoTable
                        for (int j = 0; j < DS_Cancellation_Status_Response.Tables["ETicket"].Rows.Count; j++)
                        {


                            if (Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["Cancellation_Id"]) == Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Eticketdto_Id"]))
                            {



                                SqlParameter[] paramAdult_Child_Infant_ticketInfo = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_Adult_Child_Infant_TicketInfo_Output",SqlDbType.Int,4),
                   new SqlParameter("@Booking_St_Id",Convert.ToString(ViewState["Booking_St_Id"])),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@CancellationId",Convert.ToInt32(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationId"])),                                       
                   new SqlParameter("@CancellationStatus",Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationStatus"])),   
                   new SqlParameter("@CancellationProcessDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationProcessDateTime"])), 
                   new SqlParameter("@CancellationCharges",Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationCharges"])), 
                   new SqlParameter("@RefundStatus",Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundStatus"])), 
                   new SqlParameter("@FinalRefundAmount",Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["FinalRefundAmount"])), 
                   new SqlParameter("@RefundDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundDateTime"])),                                   
                   new SqlParameter("@eticketno",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["eticketno"])),
                   new SqlParameter("@flightuid",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["flightuid"])),
                   new SqlParameter("@passuid",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["passuid"])),
                   new SqlParameter("@PnrNumber",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["PnrNumber"])), 
                   new SqlParameter("@Origin",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Origin"])), 
                   new SqlParameter("@Destination",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Destination"])),
                 

                 
                          };

                                paramAdult_Child_Infant_ticketInfo[0].Direction = ParameterDirection.Output;

                                SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_uAir_Update_Adult_Child_Infant_TicketInfo_Table", paramAdult_Child_Infant_ticketInfo);
                                string Result_paramAdult_Child_Infant_ticketInfo_Status = Convert.ToString(paramAdult_Child_Infant_ticketInfo[0].Value);



                                if (Result_paramAdult_Child_Infant_ticketInfo_Status == "1")
                                {


                                }
                                else if (Result_paramAdult_Child_Infant_ticketInfo_Status == "0")
                                {
                                    //lblerrormsg.Text = "Adult Child and Infant Ticket Info Records not update successfully";
                                }



                            }


                        }

                        #endregion

                    }



                }
            }


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


        }


    }
    public void Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response_ReturnFlight()
    {
        try
        {
            if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Processed")
            {

                if (DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count != 0)
                {


                    for (int i = 0; i < DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count; i++)
                    {
                        #region Update_Cancellation and Refund Details in Adult_Child_Infant_TicketInfoTable For Return Flight
                        for (int j = 0; j < DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows.Count; j++)
                        {


                            if (Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["Cancellation_Id"]) == Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Eticketdto_Id"]))
                            {



                                SqlParameter[] paramAdult_Child_Infant_ticketInfo = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_Adult_Child_Infant_TicketInfo_Output",SqlDbType.Int,4),
                   new SqlParameter("@Booking_St_Id",Convert.ToString(ViewState["Booking_St_Id"])),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@CancellationId",Convert.ToInt32(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationId"])),                                       
                   new SqlParameter("@CancellationStatus",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationStatus"])),   
                   new SqlParameter("@CancellationProcessDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationProcessDateTime"])), 
                   new SqlParameter("@CancellationCharges",Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationCharges"])), 
                   new SqlParameter("@RefundStatus",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundStatus"])), 
                   new SqlParameter("@FinalRefundAmount",Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["FinalRefundAmount"])), 
                   new SqlParameter("@RefundDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundDateTime"])), 
                                  

                   new SqlParameter("@eticketno",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["eticketno"])),
                   new SqlParameter("@flightuid",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["flightuid"])),
                   new SqlParameter("@passuid",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["passuid"])),
                   new SqlParameter("@PnrNumber",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["PnrNumber"])), 
                   new SqlParameter("@Origin",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Origin"])), 
                   new SqlParameter("@Destination",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Destination"])),
                 
                 
                          };

                                paramAdult_Child_Infant_ticketInfo[0].Direction = ParameterDirection.Output;

                                SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_uAir_Update_Adult_Child_Infant_TicketInfo_Table", paramAdult_Child_Infant_ticketInfo);
                                string Result_paramAdult_Child_Infant_ticketInfo_Status_Return = Convert.ToString(paramAdult_Child_Infant_ticketInfo[0].Value);



                                if (Result_paramAdult_Child_Infant_ticketInfo_Status_Return == "1")
                                {


                                }
                                else if (Result_paramAdult_Child_Infant_ticketInfo_Status_Return == "0")
                                {
                                    //lblerrormsg.Text = "Adult Child and Infant Ticket Info of Return Flight Records not update successfully";
                                }



                            }


                        }

                        #endregion

                    }



                }
            }


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


        }


    }
    public void Insert_Air_Cancellation_Details_Table_When_Status_Pending()
    {
        string Result_param_Cancellatin_Details_Pending_Rejected_Status = "";

        try
        {
            //if (Convert.ToString(ViewState["Cancellation_status"]) == "Pending")
            //{


            //    if (DS_Cancellation_Response.Tables.Contains("onwardcanceldata"))
            //    {

            //        if (DS_Cancellation_Response.Tables["onwardcanceldata"].Rows.Count != 0)
            //        {

            //            XmlDocument xDoc = new XmlDocument();
            //            xDoc.LoadXml(Convert.ToString(ViewState["Get_cancellationDetails"]));


            //            XmlNodeList xmlNodes = xDoc.GetElementsByTagName("onwardcanceldata");

            //            foreach (XmlNode xNode in xmlNodes)
            //            {
            //                XmlNodeList innerNodeList = xNode.ChildNodes;
            //                foreach (XmlNode xNodeInner in innerNodeList)
            //                {
            //                    string Canid = xNode["Canid"].InnerText;
            //                    string Cancellation_status = xNode["status"].InnerText;


            //                    if (xNodeInner.Name == "eticketdto")
            //                    {

            //                        string Cancel_EticketData = xNodeInner.OuterXml;
            
                                    DataSet ds_Cancel_Eticket = new DataSet();
                                    ds_Cancel_Eticket = (DataSet)Session["FlightInfoDepart"];
                                    int Canid = Convert.ToInt32(Session["canid"]);
                                    string Cancellation_status = Convert.ToString(Session["CancellationStatusDepart"]);

                                    #region Insert_Cancellation_Details_Table
                                    for (int i = 0; i < ds_Cancel_Eticket.Tables[0].Rows.Count; i++)
                                    {
                                         

                                        SqlParameter[] param_Cancellation_Details_Pending_Rejected = new SqlParameter[]
                                   {

                             new SqlParameter("@Result_Cancellation_Details_Status_Pending_Rejected_Output",SqlDbType.Int,4),
                             new SqlParameter("@Agent_id",Convert.ToString(Session["agid"])),
                             new SqlParameter("@Booking_St_Id",Convert.ToString(ds_Cancel_Eticket.Tables[0].Rows[i]["Booking_St_Id"])),
                             new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                             new SqlParameter("@CancellationId",Convert.ToInt32(Canid)),
                             new SqlParameter("@CancellationStatus",Cancellation_status),
                             new SqlParameter("@eticketno",Convert.ToString(ds_Cancel_Eticket.Tables[0].Rows[i]["eticketno"])), 
                             new SqlParameter("@flightuid",Convert.ToString(ds_Cancel_Eticket.Tables[0].Rows[i]["flightuid"])),
                             new SqlParameter("@passuid",Convert.ToString(ds_Cancel_Eticket.Tables[0].Rows[i]["passuid"])),
                             new SqlParameter("@JourneyType","Depart"),
                       
                                    
                                   };



                                        param_Cancellation_Details_Pending_Rejected[0].Direction = ParameterDirection.Output;

                                        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Air_Insert_Cancellation_Details_For_Pending_Rejected_Case", param_Cancellation_Details_Pending_Rejected);

                                        Result_param_Cancellatin_Details_Pending_Rejected_Status = Convert.ToString(param_Cancellation_Details_Pending_Rejected[0].Value);

                                    }


                                    if (Result_param_Cancellatin_Details_Pending_Rejected_Status == "1")
                                    {


                                    }
                                    else if (Result_param_Cancellatin_Details_Pending_Rejected_Status == "0")
                                    {
                                        //lblerrormsg.Text = "Cancellation Details For Depart flight for Pending and Rejected Records not update successfully";
                                    }

                                    #endregion


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

        }
    }
    public void Insert_Air_Cancellation_Details_Table_When_Status_Pending_For_ReturnFlight()
    {
        string Result_param_Cancellatin_Details_Pending_Rejected_Status_Return = "";
        try
        {
            //if (Convert.ToString(ViewState["Cancellation_status_Return"]) == "Pending")
            //{


            //    if (DS_Cancellation_Response.Tables.Contains("returncanceldata"))
            //    {

            //        if (DS_Cancellation_Response.Tables["returncanceldata"].Rows.Count != 0)
            //        {

            //            XmlDocument xDoc = new XmlDocument();
            //            xDoc.LoadXml(Convert.ToString(ViewState["Get_cancellationDetails"]));


            //            XmlNodeList xmlNodes = xDoc.GetElementsByTagName("returncanceldata");

            //            foreach (XmlNode xNode in xmlNodes)
            //            {
            //                XmlNodeList innerNodeList = xNode.ChildNodes;
            //                foreach (XmlNode xNodeInner in innerNodeList)
            //                {
            //                    string Canid = xNode["Canid"].InnerText;
            //                    string Cancellation_status = xNode["status"].InnerText;


            //                    if (xNodeInner.Name == "eticketdto")
                               // {

                                                        

                                    DataSet ds_Cancel_Eticket_Return = new DataSet();
                                    ds_Cancel_Eticket_Return = (DataSet)Session["FlightInfoReturn"];

                                    int Canid = Convert.ToInt32(Session["canid"]);
                                    string Cancellation_status = Convert.ToString(Session["CancellationStatusReturn"]);

                                    #region Insert_Cancellation_Details_Table
                                    for (int i = 0; i < ds_Cancel_Eticket_Return.Tables[1].Rows.Count; i++)
                                    {

                                        SqlParameter[] param_Cancellation_Details_Pending_Rejected_Return = new SqlParameter[]
                                   {
                                 
                             new SqlParameter("@Result_Cancellation_Details_Status_Pending_Rejected_Output",SqlDbType.Int,4),
                             new SqlParameter("@Agent_id",Convert.ToString(Session["agid"])),
                             new SqlParameter("@Booking_St_Id",Convert.ToString(ds_Cancel_Eticket_Return.Tables[1].Rows[i]["Booking_ST_Id"])),
                             new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                             new SqlParameter("@CancellationId",Convert.ToInt32(Canid)),
                             new SqlParameter("@CancellationStatus",Cancellation_status),
                             new SqlParameter("@eticketno",Convert.ToString(ds_Cancel_Eticket_Return.Tables[1].Rows[i]["eticketno"])), 
                             new SqlParameter("@flightuid",Convert.ToString(ds_Cancel_Eticket_Return.Tables[1].Rows[i]["flightuid"])),
                             new SqlParameter("@passuid",Convert.ToString(ds_Cancel_Eticket_Return.Tables[1].Rows[i]["passuid"])),
                             new SqlParameter("@JourneyType","Return"),
                             };





                                        param_Cancellation_Details_Pending_Rejected_Return[0].Direction = ParameterDirection.Output;

                                        SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Air_Insert_Cancellation_Details_For_Pending_Rejected_Case", param_Cancellation_Details_Pending_Rejected_Return);

                                        Result_param_Cancellatin_Details_Pending_Rejected_Status_Return = Convert.ToString(param_Cancellation_Details_Pending_Rejected_Return[0].Value);

                                    }


                                    if (Result_param_Cancellatin_Details_Pending_Rejected_Status_Return == "1")
                                    {


                                    }
                                    else if (Result_param_Cancellatin_Details_Pending_Rejected_Status_Return == "0")
                                    {
                                        //lblerrormsg.Text = "Cancellation Details For Return flight for Pending and Rejected Records not update successfully";
                                    }

                                    #endregion


                //                }

                //            }
                //        }
                //    }

                //}

            //}
        }
        catch (Exception ex)
        {

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

        }





    }
    public void Update_Air_Cancellation_Details_Table_when_Status_Processed()
    {
        try
        {
            if (Convert.ToString(ViewState["Cancellation_status_response"]) == "Processed")
            {

                if (DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count != 0)
                {


                    for (int i = 0; i < DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count; i++)
                    {
                        #region Update_Cancellation and Refund Details in Adult_Child_Infant_TicketInfoTable
                        for (int j = 0; j < DS_Cancellation_Status_Response.Tables["ETicket"].Rows.Count; j++)
                        {


                            if (Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["Cancellation_Id"]) == Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Eticketdto_Id"]))
                            {



                                SqlParameter[] param_Cancellation_Info = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_Cancellation_Details_Output",SqlDbType.Int,4),
                        //------------Edit Vk
                   new SqlParameter("@Can_Sno",SqlDbType.Int),
                   //-----Closed
                   new SqlParameter("@Agent_id",Convert.ToString(  Session["agid"])),
                   new SqlParameter("@Booking_St_Id",Convert.ToString(ViewState["Booking_St_Id"])),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@CancellationId",Convert.ToInt32(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationId"])),                                       
                   new SqlParameter("@CancellationStatus",Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationStatus"])),   
                   new SqlParameter("@CancellationProcessDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationProcessDateTime"])), 
                   new SqlParameter("@CancellationCharges",Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationCharges"])), 
                   new SqlParameter("@RefundStatus",Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundStatus"])), 
                   new SqlParameter("@FinalRefundAmount",Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["FinalRefundAmount"])), 
                   new SqlParameter("@RefundDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundDateTime"])), 
                                  

                   new SqlParameter("@eticketno",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["eticketno"])),
                   new SqlParameter("@flightuid",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["flightuid"])),
                   new SqlParameter("@Passuid",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["passuid"])),
                   new SqlParameter("@PnrNumber",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["PnrNumber"])), 
                   new SqlParameter("@Origin",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Origin"])), 
                   new SqlParameter("@Destination",Convert.ToString(DS_Cancellation_Status_Response.Tables["ETicket"].Rows[j]["Destination"])),
                 

                 
                          };

                                param_Cancellation_Info[0].Direction = ParameterDirection.Output;
                                param_Cancellation_Info[1].Direction = ParameterDirection.Output;
                                SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Air_Update_Cancellation_Details_Table", param_Cancellation_Info);
                                string Result_param_Cancellation_Info_Status = Convert.ToString(param_Cancellation_Info[0].Value);

                                //---------Edit By Vinod Find C_no-----
                                ViewState["Can_Sno"] = param_Cancellation_Info[1].Value;
                                //-----------------



                                if (Result_param_Cancellation_Info_Status == "1")
                                {
                                     

                                }
                                else if (Result_param_Cancellation_Info_Status == "0")
                                {
                                    //lblerrormsg.Text = "Cancellation Details of Depart flights Records not update successfully";
                                }



                            }


                        }

                        #endregion

                    }



                }
            }


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


        }


    }
    public void Update_Air_Cancellation_Details_Table_when_Status_Processed_for_ReturnFlight()
    {
        try
        {
            if (Convert.ToString(ViewState["Cancellation_status_response_Return"]) == "Processed")
            {

                if (DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count != 0)
                {


                    for (int i = 0; i < DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count; i++)
                    {
                        #region Update_Cancellation and Refund Details in Adult_Child_Infant_TicketInfoTable For Return Flight
                        for (int j = 0; j < DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows.Count; j++)
                        {


                            if (Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["Cancellation_Id"]) == Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Eticketdto_Id"]))
                            {



                                SqlParameter[] param_Cancellation_Info = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_Cancellation_Details_Output",SqlDbType.Int,4),
                    //------------Edit Vk
                   new SqlParameter("@Can_Sno",SqlDbType.Int),
                   //-----Closed
                   new SqlParameter("@Agent_id",Convert.ToString(  Session["agid"])),
                   new SqlParameter("@Booking_St_Id",Convert.ToString(ViewState["Booking_St_Id"])),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@CancellationId",Convert.ToInt32(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationId"])),                                       
                   new SqlParameter("@CancellationStatus",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationStatus"])),   
                   new SqlParameter("@CancellationProcessDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationProcessDateTime"])), 
                   new SqlParameter("@CancellationCharges",Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationCharges"])), 
                   new SqlParameter("@RefundStatus",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundStatus"])), 
                   new SqlParameter("@FinalRefundAmount",Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["FinalRefundAmount"])), 
                   new SqlParameter("@RefundDateTime",Convert.ToDateTime(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundDateTime"])), 
                                  

                   new SqlParameter("@eticketno",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["eticketno"])),
                   new SqlParameter("@flightuid",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["flightuid"])),
                   new SqlParameter("@Passuid",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["passuid"])),
                   new SqlParameter("@PnrNumber",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["PnrNumber"])), 
                   new SqlParameter("@Origin",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Origin"])), 
                   new SqlParameter("@Destination",Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["ETicket"].Rows[j]["Destination"])),
                 

                 
                          };

                                param_Cancellation_Info[0].Direction = ParameterDirection.Output;
                                param_Cancellation_Info[1].Direction = ParameterDirection.Output;
                                SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Air_Update_Cancellation_Details_Table", param_Cancellation_Info);
                                string Result_param_Cancellation_Info_Status_Return = Convert.ToString(param_Cancellation_Info[0].Value);
                                //---------Edit By Vinod Find C_no-----
                                ViewState["Can_Sno_return"] = param_Cancellation_Info[1].Value;
                                //-----------------



                                if (Result_param_Cancellation_Info_Status_Return == "1")
                                {

                          
                                }
                                else if (Result_param_Cancellation_Info_Status_Return == "0")
                                {
                                    //lblerrormsg.Text = "Cancellation Details of Return flights Records not update successfully";
                                }



                            }


                        }

                        #endregion

                    }



                }
            }


        }
        catch (Exception ex)
        {

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

        }


    }
    public void Update_Air_All_Table_When_Refund_Status_Processed()
    {
        try
        {
            if (Convert.ToString(ViewState["Refund_status_response"]) == "Processed")
            {
                if (DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count != 0)
                {

                    #region Update_agent_transaction_details,agent_amount and All realated Table have Status Column When Refund Status is Processed
                    Total_FinalRefundAmt = 0;
                    Total_CancelationCharge = 0;
                    for (int i = 0; i < DS_Cancellation_Status_Response.Tables["Cancellation"].Rows.Count; i++)
                    {


                        Total_FinalRefundAmt = Total_FinalRefundAmt + Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["FinalRefundAmount"]);
                        //vk
                        Total_CancelationCharge = Total_CancelationCharge + Convert.ToDecimal(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["CancellationCharges"]);
                        //closed vk
                        Current_Rfnd_Status = Convert.ToString(DS_Cancellation_Status_Response.Tables["Cancellation"].Rows[i]["RefundStatus"]);


                    }
                    //________________Change New--03/AGUST-----
                 //   ViewState["Total_FinalRefundAmt_depart"] = Total_FinalRefundAmt;
                  //  ViewState["Total_CancelationCharge_depart"] = Total_CancelationCharge;
                    //--------------

                    SqlParameter[] param_ForAll_refundedCaseTable = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_RefundedCaseProcessed_Status_Output",SqlDbType.Int,4),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@Tran_status","Refunded"),                 
                   new SqlParameter("@UpdIpAddress",sys_IP),
                   new SqlParameter("@FinalRefundAmount",Total_FinalRefundAmt), 
                   new SqlParameter("@Remark",Current_Rfnd_Status), 
                   new SqlParameter("@Can_Sno",Convert.ToString(ViewState["Can_Sno"])),
              
                          };

                    param_ForAll_refundedCaseTable[0].Direction = ParameterDirection.Output;

                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Update_Refund_Status_Proceessd_Related_AllTable", param_ForAll_refundedCaseTable);
                    string Result_ForAll_refundedCase_Table_Status = Convert.ToString(param_ForAll_refundedCaseTable[0].Value);



                    if (Result_ForAll_refundedCase_Table_Status == "1")
                    {
                        B2B objb2b = new B2B();
                      //  objb2b.Credit_Agent_Amount_Insertin_ATT(Convert.ToString(Session["agid"]), Total_FinalRefundAmt, Convert.ToString(ViewState["partnerRefId"]), Convert.ToString(Session["distributor"]), Request.UserHostAddress, "Dom Flight Cancellation", Convert.ToString(Session["HURL"]));
                        objb2b.InsertTransactionWithCancelStatus(Session["WhitelabelId"].ToString(), Request.UserHostAddress, Convert.ToString(ViewState["partnerRefId"]), Convert.ToString(Session["agid"]), "60", "", Total_FinalRefundAmt, "GI Flihgt", Session["PortalName"].ToString(), "Dom Flight Cancellation");
                        Session["agent_amount"] = Convert.ToDecimal(objb2b.CheckAgentBalance(Convert.ToString(Session["agid"]), Convert.ToString(Session["HURL"])));  //get the latest amount             
                 
                      //SendMailDepart();
                    }
                    else if (Result_ForAll_refundedCase_Table_Status == "0")
                    {
                        //lblerrormsg.Text = "Refund Staus Processed Related Table Records not update successfully";
                    }

                    #endregion


                }
            }


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


        }


    }
    public void Update_Air_All_Table_When_Refund_Status_Processed_ReturnFlight()
    {

        try
        {
            if (Convert.ToString(ViewState["Refund_status_response_Return"]) == "Processed")
            {
                if (DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count != 0)
                {

                    #region Update_agent_transaction_details,agent_amount and All realated Table have Status Column When Refund Status is Processed For Return Flight

                    Total_FinalRefundAmt_Return = 0;
                    Total_CancelationCharge = 0;
                    for (int i = 0; i < DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows.Count; i++)
                    {



                        Total_FinalRefundAmt_Return = Total_FinalRefundAmt_Return + Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["FinalRefundAmount"]);
                        //vk
                        Total_CancelationCharge = Total_CancelationCharge + Convert.ToDecimal(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["CancellationCharges"]);
                        //vk
                        Current_Rfnd_Status_Return = Convert.ToString(DS_Cancellation_Status_Response_Return.Tables["Cancellation"].Rows[i]["RefundStatus"]);


                    }

                    SqlParameter[] param_ForAll_refundedCaseTable = new SqlParameter[]
                          {
                          
                   new SqlParameter("@Result_RefundedCaseProcessed_Status_Output",SqlDbType.Int,4),
                   new SqlParameter("@partnerRefId",Convert.ToString(ViewState["partnerRefId"])),
                   new SqlParameter("@Tran_status","Refunded"),
 
                   new SqlParameter("@UpdIpAddress",sys_IP),
                   new SqlParameter("@FinalRefundAmount",Total_FinalRefundAmt_Return), 
                   new SqlParameter("@Remark",Current_Rfnd_Status_Return),
                      //vk
                   new SqlParameter("@Can_Sno",Convert.ToString(ViewState["Can_Sno_return"])),
                       
                 
                          };

                    param_ForAll_refundedCaseTable[0].Direction = ParameterDirection.Output;

                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "B2B_Update_Refund_Status_Proceessd_Related_AllTable", param_ForAll_refundedCaseTable);
                    string Result_ForAll_refundedCase_Table_Status_Return = Convert.ToString(param_ForAll_refundedCaseTable[0].Value);

                    if (Result_ForAll_refundedCase_Table_Status_Return == "1")
                    {
                        B2B objb2b = new B2B();
                        objb2b.InsertTransactionWithCancelStatus(Session["WhitelabelId"].ToString(), Request.UserHostAddress, Convert.ToString(ViewState["partnerRefId"]), Convert.ToString(Session["agid"]), "60", "", Total_FinalRefundAmt_Return, "GI Flihgt", Session["PortalName"].ToString(), "Dom Flight Cancellation");
                        //objb2b.Credit_Agent_Amount_Insertin_ATT(Convert.ToString(Session["agid"]), Total_FinalRefundAmt_Return, Convert.ToString(ViewState["partnerRefId"]), Convert.ToString(Session["distributor"]), Request.UserHostAddress, "Dom Flight Cancellation", Convert.ToString(Session["HURL"]));

                        Session["agent_amount"] = Convert.ToDecimal(objb2b.CheckAgentBalance(Convert.ToString(Session["agid"]), Convert.ToString(Session["HURL"])));  //get the latest amount             
                 

                        // update amount here
                        //Wallet_PG_Process wall = new Wallet_PG_Process();
                        //wall.WalletTransaction(Convert.ToString(ViewState["partnerRefId"]) + "-" + Convert.ToString(ViewState["Can_Sno_return"]), Convert.ToString(Session["user_id"]), Total_FinalRefundAmt_Return, "ARZOO", "WALLET", "Domestic Refund Return", "CREDIT");

                       // SendMailDepart_return();
                    }
                    else if (Result_ForAll_refundedCase_Table_Status_Return == "0")
                    {
                        //lblerrormsg.Text = "Refund Staus Processed Related Table For Return Flight Records not update successfully";
                    }

                    #endregion


                }
            }


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

        }


    }
    private void SendMailDepart()
    {
  
        try
        {

            int canid = Convert.ToInt32(ViewState["Cancellation_id"]);
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Get_Cancellationdetails_for_Mail_Domestic", new SqlParameter[] { new SqlParameter("@canid", canid) });

            string noofpass = Convert.ToString(ds.Tables[0].Rows[0][0]);
            string Origin = Convert.ToString(ds.Tables[2].Rows[0][0]);
            string Destination = Convert.ToString(ds.Tables[2].Rows[0][1]);
            string DepartDateTime = Convert.ToDateTime(Convert.ToString(ds.Tables[1].Rows[0][0])).ToString("dd-MM-yyyy hh:mm:ss tt");
            string ArrivalDateTime = Convert.ToDateTime(Convert.ToString(ds.Tables[1].Rows[ds.Tables[1].Rows.Count - 1][1])).ToString("dd-MM-yyyy hh:mm:ss tt"); ;
            string airlinename = Convert.ToString(ds.Tables[1].Rows[0][2]);
            string flightinfo = Convert.ToString(ds.Tables[1].Rows[0][3]);
            string pnrnumber = Convert.ToString(ds.Tables[1].Rows[0][4]);

            string html = @"
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
     <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
 
<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  " + Convert.ToString(Session["ScreenName"]) + @",</p></td>
  </tr>
  <tr>
    <td height='25' align='left' valign='top'><p class='txt_2'>You have cancelled a 
        ticket against Air E-Point reference number " + Convert.ToString(ViewState["partnerRefId"]) + @". Please find below details of 
        cancelled ticket:<br />
        <br />
    </p>
    </td>
  </tr>
  <tr>
    <td align='left' valign='top'>
        <table width='100%' border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <th width='24%' height='40' colspan='4' align='left' class='txt_2' scope='col'><strong>" + Origin + @"--> " + Destination + @" </strong></th>
         
          </tr>
          <tr>
            <td align='left' class='txt_2'><strong>Flight:</strong> " + flightinfo + @" </td>
            <td align='left' class='txt_2'><strong>From:</strong> " + Origin + @"</td>
            <td align='left' class='txt_2'><strong>Departs:</strong> " + DepartDateTime + @"</td>
            <td align='left' class='txt_2'><strong>Ticket:</strong> " + pnrnumber + @" </td>
          </tr>
          <tr>
            <td align='left' class='txt_2'><strong>Airline:</strong> " + airlinename + @" </td>
            <td align='left' class='txt_2'><strong>To:</strong> " + Destination + @"</td>
            <td align='left' class='txt_2'><strong>Arrives:</strong> " + ArrivalDateTime + @"</td>
            <td align='left' class='txt_2'><strong>No. of Passenger Cancelled:</strong> " + noofpass + @"</td>
          </tr>
      </table>
       
  </tr>
  <tr>
    <td height='20' align='left' valign='top'><p class='txt_2'><span class='txt_2'><br />
      Happy to serve you,</span><br />
      <br />
    </p></td>
  </tr>
  <tr>
    <td><div style='mso-element:para-border-div;border-top:solid windowtext 1.0pt;
border-left:none;border-bottom:solid windowtext 1.0pt;border-right:none;
mso-border-top-alt:solid windowtext .5pt;mso-border-bottom-alt:solid windowtext .5pt;
padding:3.0pt 0in 3.0pt 0in'><span class='txt_2'>Air E-Point Team</span><br />
    <a href='http://www.airepoint.com'>www.airepoint.com</a></div></td>
  </tr>
</table>

</body>
</html>
";

            MailMessage mail = new MailMessage();
            //mail.To.Add(Session["emailid"].ToString());
            mail.To.Add("support@commsoft.in");
            //mail.To.Add("puneet.n@commsoft.in");
            mail.From = new MailAddress("info@hotel.travelepoint.in");
            mail.Subject = "Air Cancellation Request – " + pnrnumber + " .";
            mail.Body = "Air Cancellation Request has been made by " + Convert.ToString(Session["fagid"]) + " .";
            mail.Bcc.Add("txn@onecard.co.in");
            mail.IsBodyHtml = true;
            mail.Priority = MailPriority.High;
            var a = Attachment.CreateAttachmentFromString(html, "Ticket.html");
            mail.Attachments.Add(a);

            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(mail);


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

        try
        {

            int canid = Convert.ToInt32(ViewState["Cancellation_id_Return"]);
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Get_Cancellationdetails_for_Mail_Domestic", new SqlParameter[] { new SqlParameter("@canid", canid) });

            string noofpass = Convert.ToString(ds.Tables[0].Rows[0][0]);
            string Origin = Convert.ToString(ds.Tables[2].Rows[0][0]);
            string Destination = Convert.ToString(ds.Tables[2].Rows[0][1]);
            string DepartDateTime = Convert.ToDateTime(Convert.ToString(ds.Tables[1].Rows[0][0])).ToString("dd-MM-yyyy hh:mm:ss tt");
            string ArrivalDateTime = Convert.ToDateTime(Convert.ToString(ds.Tables[1].Rows[ds.Tables[1].Rows.Count - 1][1])).ToString("dd-MM-yyyy hh:mm:ss tt"); ;
            string airlinename = Convert.ToString(ds.Tables[1].Rows[0][2]);
            string flightinfo = Convert.ToString(ds.Tables[1].Rows[0][3]);
            string pnrnumber = Convert.ToString(ds.Tables[1].Rows[0][4]);

            string html = @"
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
     <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
 
<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 " + Convert.ToString(Session["ScreenName"]) + @",</p></td>
  </tr>
  <tr>
    <td height='25' align='left' valign='top'><p class='txt_2'>You have cancelled a 
        ticket against Air E-Point reference number " + Convert.ToString(ViewState["partnerRefId"]) + @". Please find below details of 
        cancelled ticket:<br />
        <br />
    </p>
    </td>
  </tr>
  <tr>
    <td align='left' valign='top'>
        <table width='100%' border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <th width='24%' height='40' colspan='4' align='left' class='txt_2' scope='col'><strong>" + Origin + @"--> " + Destination + @" </strong></th>
         
          </tr>
          <tr>
            <td align='left' class='txt_2'><strong>Flight:</strong> " + flightinfo + @" </td>
            <td align='left' class='txt_2'><strong>From:</strong> " + Origin + @"</td>
            <td align='left' class='txt_2'><strong>Departs:</strong> " + DepartDateTime + @"</td>
            <td align='left' class='txt_2'><strong>Ticket:</strong> " + pnrnumber + @" </td>
          </tr>
          <tr>
            <td align='left' class='txt_2'><strong>Airline:</strong> " + airlinename + @" </td>
            <td align='left' class='txt_2'><strong>To:</strong> " + Destination + @"</td>
            <td align='left' class='txt_2'><strong>Arrives:</strong> " + ArrivalDateTime + @"</td>
            <td align='left' class='txt_2'><strong>No. of Passenger Cancelled:</strong> " + noofpass + @"</td>
          </tr>
      </table>
       
  </tr>
  <tr>
    <td height='20' align='left' valign='top'><p class='txt_2'><span class='txt_2'><br />
      Happy to serve you,</span><br />
      <br />
    </p></td>
  </tr>
  <tr>
    <td><div style='mso-element:para-border-div;border-top:solid windowtext 1.0pt;
border-left:none;border-bottom:solid windowtext 1.0pt;border-right:none;
mso-border-top-alt:solid windowtext .5pt;mso-border-bottom-alt:solid windowtext .5pt;
padding:3.0pt 0in 3.0pt 0in'><span class='txt_2'>Air E-Point Team</span><br />
    <a href='http://www.airepoint.com'>www.airepoint.com</a></div></td>
  </tr>
</table>

</body>
</html>
";

            MailMessage mail = new MailMessage();
            //mail.To.Add(Session["emailid"].ToString());
            mail.To.Add("support@commsoft.in");
            //mail.To.Add("puneet.n@commsoft.in");
            mail.From = new MailAddress("info@hotel.travelepoint.in");
            mail.Subject = "Air Cancellation Request – " + pnrnumber + " .";
            mail.Body = "Air Cancellation Request has been made by " + Convert.ToString(Session["fagid"]) + " .";
            mail.Bcc.Add("txn@onecard.co.in");
            mail.IsBodyHtml = true;
            mail.Priority = MailPriority.High;
            var a = Attachment.CreateAttachmentFromString(html, "Ticket.html");
            mail.Attachments.Add(a);


            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(mail);


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


    //void SendCancellationRequestAndUpdateTables(string CancellationId)
    //{
    //    try
    //    {
    //        Cancellation_Status_request = "<EticketCanStatusReq><Clientid>" + Clientid + "</Clientid><Clientpassword>" + Clientpassword + "</Clientpassword><Clienttype>" + Clienttype + "</Clienttype><transid>" + Convert.ToString(ViewState["transid"]) + "</transid><partnerRefId>" + Convert.ToString(ViewState["partnerRefId"]) + "</partnerRefId><CancellationId>" + CancellationId + "</CancellationId></EticketCanStatusReq>";
    //        obj_AirEpointSupport.WriteXmlLog(Cancellation_Status_request, "Domestic_CancellationStatus_Request__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Request = new DataSet();
    //        DS_Cancellation_Status_Request.ReadXml(new StringReader(Convert.ToString(Cancellation_Status_request)));



    //        DOMFlightCancellationStatus domfs = new DOMFlightCancellationStatus();
    //        string Get_Cancellation_Status = domfs.getCancelationStatus(Convert.ToString(Cancellation_Status_request));
    //        obj_AirEpointSupport.WriteXmlLog(Get_Cancellation_Status, "Domestic_CancellationStatus_Response__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Response = new DataSet();
    //        DS_Cancellation_Status_Response.ReadXml(new StringReader(Convert.ToString(Get_Cancellation_Status)));


    //        Get_Cancellation_Status_Response_For_UpdateTable();  //read cancel status Pending,Processed,Rejected
    //        //read refund status  Pending,Processed


    //        //  update  adult child infant ticket status  if cancellation status is pending or processed
    //   //-------By LAVI ----------
    //    //    Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_DepartFlight();  //if pending  
    //        //______

    //        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response();  //if processed

    //        //  insert in  cancellation table insert first time when pending else update when processed
    //        //___ LAVI
    //      //  Insert_Air_Cancellation_Details_Table_When_Status_Pending();  //if pending
    //        //________
    //        Update_Air_Cancellation_Details_Table_when_Status_Processed();  //if processed


    //        // if refund status is processes then update in transaction details table about amounts 
    //        Update_Air_All_Table_When_Refund_Status_Processed();   //refund

 
    //    }
    //    catch (Exception ex)
    //    {
    //        AirEpointSupport ob = new AirEpointSupport();
    //        ob.WriteToLog(ex.Message, "Cancel.aspx", "SendCancellationRequestAndUpdateTables__" + Convert.ToString(ViewState["partnerRefId"]));
    //        Response.Redirect("../User/index.aspx?s=exception");
    //    }
    //}
    // protected void link_pass1_Click(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        string id = ((LinkButton)(sender)).ID;
    //        id = id.Replace("link_pass", string.Empty);
    //        string canid = ((Label)(tblpassinfo.FindControl("lbl_canid" + id))).Text;
    //        SendCancellationRequestAndUpdateTables(canid);
    //        //________
    //        flightinfo();
    //        passinfo(checkforCancellable());
    //    }

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


    //protected void link_pass1_Click_return(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        string id = ((LinkButton)(sender)).ID;
    //        id = id.Replace("link_pass", string.Empty);
    //        string canid = ((Label)(tblpassinfo.FindControl("lbl_canid" + id))).Text;
    //        SendCancellationRequestAndUpdateTables_return(canid);
    //        //________
    //        flightinfo();
    //        passinfo(checkforCancellable());
    //    }
    //    catch (Exception ex)
    //    {
    //        obj_AirEpointSupport.WriteToLog(ex.Message, "Cancel", "link_pass1_Click_return__" + Convert.ToString(ViewState["partnerRefId"]));
    //        Response.Redirect("../User/index.aspx?s=exception");
    //    }
    //}
    //void SendCancellationRequestAndUpdateTables_return(string CancellationId)
    //{
    //    try
    //    {




    //        Cancellation_Status_request_Return = "<EticketCanStatusReq><Clientid>" + Clientid + "</Clientid><Clientpassword>" + Clientpassword + "</Clientpassword><Clienttype>" + Clienttype + "</Clienttype><transid>" + Convert.ToString(ViewState["transid"]) + "</transid><partnerRefId>" + Convert.ToString(ViewState["partnerRefId"]) + "</partnerRefId><CancellationId>" + CancellationId + "</CancellationId></EticketCanStatusReq>";
    //        DS_Cancellation_Status_Request_Return = new DataSet();
    //        DS_Cancellation_Status_Request_Return.ReadXml(new StringReader(Convert.ToString(Cancellation_Status_request_Return)));


    //        obj_AirEpointSupport.WriteXmlLog(Cancellation_Status_request_Return, "Domestic_CancellationStatus_Request_Return__" + Convert.ToString(ViewState["partnerRefId"]));

    //        DOMFlightCancellationStatus domfs = new DOMFlightCancellationStatus();
    //        string Get_Cancellation_Status_Response = domfs.getCancelationStatus(Convert.ToString(Cancellation_Status_request_Return));
    //        obj_AirEpointSupport.WriteXmlLog(Get_Cancellation_Status_Response, "Domestic_CancellationStatus_Response_Return__" + Convert.ToString(ViewState["partnerRefId"]));
    //        DS_Cancellation_Status_Response_Return = new DataSet();
    //        DS_Cancellation_Status_Response_Return.ReadXml(new StringReader(Convert.ToString(Get_Cancellation_Status_Response)));


    //        Get_Cancellation_Status_Response_For_UpdateTable_ReturnFlight();
    //        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight();
    //        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response_ReturnFlight();
    //        Insert_Air_Cancellation_Details_Table_When_Status_Pending_For_ReturnFlight();
    //        Update_Air_Cancellation_Details_Table_when_Status_Processed_for_ReturnFlight();
    //        Update_Air_All_Table_When_Refund_Status_Processed_ReturnFlight();
    //    }
    //    catch (Exception ex)
    //    {
    //        AirEpointSupport ob = new AirEpointSupport();
    //        ob.WriteToLog(ex.Message, "Cancel.aspx", "SendCancellationRequestAndUpdateTables_return__" + Convert.ToString(ViewState["partnerRefId"]));
    //        Response.Redirect("../User/index.aspx?s=exception");
    //    }
    //}
    protected void btn_back_Click(object sender, EventArgs e)
    {
        Session["partnerrefidtrip"] = ViewState["partnerRefId"];
       // Response.Redirect("../Transaction/Transaction.aspx");
    }
    protected void btn_home__return_Click(object sender, EventArgs e)
    {
        Session["partnerrefidtrip"] = ViewState["partnerRefId"];
      //  Response.Redirect("../Transaction/Transaction.aspx");
    }
    protected void btn_cancel_Click(object sender, EventArgs e)
    {
        int Flag = 0;
          Session.Remove("canid");
        Hermes hh = new Hermes();
        AirEpointSupport airepont = new AirEpointSupport();
        DataSet cancres = new DataSet();
        DataTable dtt = (DataTable)Session["CancellationResponseDepart"];

        for (int i = 0; i < dtt.Rows.Count; i++)
        {
            if (((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + (i + 1).ToString()))).Checked == true)
            {
                Flag = 1;
            }
        }
        Session["canid"] = hh.Generate_CanID();
        if (Flag == 1)
        {
            //DataTable dtt = (DataTable)Session["CancellationResponseDepart"];
            string CancelSubmit = @"<CancelSubmit>
<HermesPNR>" + Convert.ToString(Session["HermesPNR"]) + @"</HermesPNR>
<AirlinePNR>" + Convert.ToString(Session["PNRNoDepart"]) + @"</AirlinePNR>
<CRSPNR />
<PassengerDetails>";
            DataTable Details = new DataTable();

            for (int i = 0; i < dtt.Rows.Count; i++)
            {
                if (((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + (i + 1).ToString()))).Checked == true)
                {
                    string text = ((Label)(tblpassinfo.FindControl("paxid" + (i + 1).ToString()))).Text.ToString();
                    CancelSubmit = CancelSubmit + @"
<item>
<PaxNo>" + text.ToString() + @"</PaxNo>
<TicketDetails>";
                    Details = (from dt2 in dtt.AsEnumerable()
                               where dt2.Field<string>("PaxNo") == text.ToString()
                               select dt2).CopyToDataTable();

                    for (int j = 0; j < Details.Rows.Count; j++)
                    {

                        CancelSubmit = CancelSubmit + @"
<item>
  <TicketNo>" + Details.Rows[j]["TicketNo"].ToString() + @"</TicketNo>
  <SegmentId>" + Details.Rows[j]["Segmentid"].ToString() + @"</SegmentId>
  <FlightNo>" + Details.Rows[j]["FlightNumber"].ToString() + @"</FlightNo>
  <Source>" + Details.Rows[j]["Origin"].ToString() + @"</Source>
  <Destiantion>" + Details.Rows[j]["Destination"].ToString() + @"</Destiantion>
</item>";
                    }

                    CancelSubmit = CancelSubmit + @"
</TicketDetails>
</item>";
                }
            }
            CancelSubmit = CancelSubmit + @"
</PassengerDetails>
</CancelSubmit>";


            
            string cancelSubmit_Response_Depart = hh.Dom_Cancellation_Submit(CancelSubmit);
           
            airepont.WriteXmlLog(cancelSubmit_Response_Depart, Convert.ToString(Session["partnerRefId"]) + "_Domestic_CancellationResponseDepart" + DateTime.Now.ToLongDateString() + ".xml");

            
            string Remarks;
            cancres.ReadXml(new StringReader(cancelSubmit_Response_Depart));

            if (cancres.Tables[0].Rows[0]["Status"].ToString() == "1")
            {
                ViewState["CancellationStatus"] = "Pending";
                Remarks = cancres.Tables[0].Rows[0]["Remarks"].ToString();
                Session["CancellationStatusDepart"] = ViewState["CancellationStatus"];
                Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_DepartFlight();

            }
            else if (cancres.Tables[0].Rows[0]["Status"].ToString() == "0")
            {
                ViewState["CancellationStatus"] = "Error";
                Remarks = cancres.Tables[1].Rows[0]["Remarks"].ToString();
            }
            else
            {
                ViewState["CancellationStatus"] = "Already Cancelled";
                Remarks = cancres.Tables[1].Rows[0]["Remarks"].ToString();
            }
            Page.RegisterStartupScript("XXX", "<script> alert('" + Remarks + "')</script>");

        }


        //////////////////////////////////

        else 
        {
          
            if (Convert.ToString(Session["journeymode"]) == "Return")
            {
                DataTable dtt2 = (DataTable)Session["CancellationResponseReturn"];
                string CancelSubmitReturn = @"<CancelSubmit>
<HermesPNR>" + Convert.ToString(Session["HermesPNRReturn"]) + @"</HermesPNR>
<AirlinePNR>" + Convert.ToString(Session["PNRNoReturn"]) + @"</AirlinePNR>
<CRSPNR />
<PassengerDetails>";

                DataTable DetailsReturn = new DataTable();
                for (int i = 0; i < dtt2.Rows.Count; i++)
                {
                    if (((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + (i + 1).ToString() + "_return"))).Checked == true)
                    {
                        string text1 = ((Label)(tblpassinfo_return.FindControl("paxid" + (i + 1).ToString() + "_return"))).Text.ToString();
                        CancelSubmitReturn = CancelSubmitReturn + @"
<item>
<PaxNo>" + text1.ToString() + @"</PaxNo>
<TicketDetails>";
                        DetailsReturn = (from dt2 in dtt2.AsEnumerable()
                                         where dt2.Field<string>("PaxNo") == text1.ToString()
                                         select dt2).CopyToDataTable();

                        for (int j = 0; j < DetailsReturn.Rows.Count; j++)
                        {

                            CancelSubmitReturn = CancelSubmitReturn + @"
<item>
  <TicketNo>" + DetailsReturn.Rows[j]["TicketNo"].ToString() + @"</TicketNo>
  <SegmentId>" + DetailsReturn.Rows[j]["Segmentid"].ToString() + @"</SegmentId>
  <FlightNo>" + DetailsReturn.Rows[j]["FlightNumber"].ToString() + @"</FlightNo>
  <Source>" + DetailsReturn.Rows[j]["Origin"].ToString() + @"</Source>
  <Destiantion>" + DetailsReturn.Rows[j]["Destination"].ToString() + @"</Destiantion>
</item>";
                        }

                        CancelSubmitReturn = CancelSubmitReturn + @"
</TicketDetails>
</item>";
                    }
                }
                CancelSubmitReturn = CancelSubmitReturn + @"
</PassengerDetails>
</CancelSubmit>";



                string cancelSubmit_Response_Return = hh.Dom_Cancellation_Submit(CancelSubmitReturn);

                airepont.WriteXmlLog(cancelSubmit_Response_Return, Convert.ToString(Session["partnerRefId"]) + "_Domestic_CancellationResponseReturn" + DateTime.Now.ToLongDateString() + ".xml");
                DataSet cancres_return = new DataSet();
                string Remarks_Return;
                cancres_return.ReadXml(new StringReader(cancelSubmit_Response_Return));

                if (cancres_return.Tables[0].Rows[0]["Status"].ToString() == "1")
                {
                    ViewState["CancellationStatusReturn"] = "Pending";
                    Remarks_Return = cancres_return.Tables[0].Rows[0]["Remarks"].ToString();
                    Session["CancellationStatusReturn"] = ViewState["CancellationStatusReturn"];
                    Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight();

                }
                else if (cancres_return.Tables[0].Rows[0]["Status"].ToString() == "0")
                {
                    Session["CancellationStatusReturn"] = "Pending";
                    Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight();
                    ViewState["CancellationStatusReturn"] = "Error";
                    Remarks_Return = cancres_return.Tables[1].Rows[0]["Remarks"].ToString();
                }
                else
                {
                    ViewState["CancellationStatusReturn"] = "Already Cancelled";
                    Remarks_Return = cancres_return.Tables[1].Rows[0]["Remarks"].ToString();
                }

            }
    }
    }
    
    protected void popupreturnYES_Click(object sender, EventArgs e)
    {
        
   
        
        try
        {
          
                DataSet ds = ((DataSet)ViewState["passinfo"]);
                int count = 0;
                for (int i = 1; i <= ds.Tables[1].Rows.Count; i++)
                {
                    count++;
                    if (((CheckBox)(tblpassinfo_return.FindControl("chkbx_pass" + i.ToString() + "_return"))).Checked)
                    {
                        Eticket = Eticket + "<Eticket><givenName>" + ds.Tables[1].Rows[i - 1]["FirstName"].ToString() + "</givenName><surName>" + ds.Tables[1].Rows[i - 1]["LastName"].ToString() + "</surName><nameReference>" + ds.Tables[1].Rows[i - 1]["Title"].ToString() + "</nameReference><eticketno>" + ds.Tables[1].Rows[i - 1]["eticketno"].ToString() + "</eticketno><flightuid>" + ds.Tables[1].Rows[i - 1]["flightuid"].ToString() + "</flightuid><passuid>" + ds.Tables[1].Rows[i - 1]["passuid"].ToString() + "</passuid></Eticket>";


                        ViewState["eticketdto"] = "<eticketdto>" + Eticket + "</eticketdto>";
                    }
                }
                if (count > 0)
                {
                    #region Call Function Send Cancellation Request and Get cancellation details Response --- Call Cancellation STatus Request and Cancellation Status Response
                //    Get_Cancellation_Request_Response();  //send cancellation request first time

                    if (DS_Cancellation_Response.Tables.Contains("CancelationDetails"))
                    {
                        if (DS_Cancellation_Response.Tables["CancelationDetails"].Rows.Count != 0)
                        {

                            if ((DS_Cancellation_Response.Tables["CancelationDetails"].Columns.Contains("error")))
                            {
                                //  lbl_cancellationResponse.Text = Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]);
                                RegisterClientScriptBlock("alert", "<script>alert('" + Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]) + "');</script>");
                                ViewState["Cancellation_Response_error"] = Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]);


                            }
                        }
                    }

                    if (DS_Cancellation_Response.Tables.Contains("onwardcanceldata"))
                    {

                        if (DS_Cancellation_Response.Tables["onwardcanceldata"].Rows.Count != 0)
                        {
                            #region Send Cancellation Status Request and Get Cancellation Status Response xml

                            ViewState["Cancellation_id"] = Convert.ToString(DS_Cancellation_Response.Tables["onwardcanceldata"].Rows[0]["Canid"]);
                            ViewState["Cancellation_status"] = Convert.ToString(DS_Cancellation_Response.Tables["onwardcanceldata"].Rows[0]["status"]);

                       //     Get_Cancellation_Status_Request_Response();  //send cancellation request if there is no error tag first time that is request has been send...  and  now send cancellation status request

                            Get_Cancellation_Status_Response_For_UpdateTable();  //read cancel status Pending,Processed,Rejected
                            //read refund status  Pending,Processed


                            //  update  adult child infant ticket status  if cancellation status is pending or processed
                            Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_DepartFlight();  //if pending  
                            Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response();  //if processed

                            //  insert in  cancellation table insert first time when pending else update when processed
                            Insert_Air_Cancellation_Details_Table_When_Status_Pending();  //if pending
                            Update_Air_Cancellation_Details_Table_when_Status_Processed();  //if processed


                            // if refund status is processes then update in transaction details table about amounts 
                            Update_Air_All_Table_When_Refund_Status_Processed();   //refund


                            #endregion

                        }

                    }


                    if (DS_Cancellation_Response.Tables.Contains("returncanceldata"))
                    {

                        if (DS_Cancellation_Response.Tables["returncanceldata"].Rows.Count != 0)
                        {
                            #region Send Cancellation Status Request and Get Cancellation Status Response xml

                            ViewState["Cancellation_id_Return"] = Convert.ToString(DS_Cancellation_Response.Tables["returncanceldata"].Rows[0]["Canid"]);
                            ViewState["Cancellation_status_Return"] = Convert.ToString(DS_Cancellation_Response.Tables["returncanceldata"].Rows[0]["status"]);

                        //    Get_Cancellation_Status_Request_Response_Return();
                            Get_Cancellation_Status_Response_For_UpdateTable_ReturnFlight();
                            Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight();
                            Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response_ReturnFlight();
                            Insert_Air_Cancellation_Details_Table_When_Status_Pending_For_ReturnFlight();
                            Update_Air_Cancellation_Details_Table_when_Status_Processed_for_ReturnFlight();
                            Update_Air_All_Table_When_Refund_Status_Processed_ReturnFlight();


                            #endregion

                        }

                    }



                    #endregion
                    // Bind_Cancellation_ticket_details();
                }
                else
                {
                    Page.RegisterStartupScript("XXX", "<script> alert('Please select at least 1 Ticket to Cancel.')</script>");

                }

         
            //________
            flightinfo();
            passinfo(checkforCancellable());
            
        }
        catch (Exception ex)
        {
            obj_AirEpointSupport.WriteToLog(ex.Message, "Cancel", "btn_home_cancel_Click_return__" + Convert.ToString(ViewState["partnerRefId"]));
            Response.Redirect("../User/index.aspx?s=exception");

        }
    
    }
    
    protected    void popupdepartYES_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet ds = ((DataSet)ViewState["passinfo"]);

            int count = 0;
            for (int i = 1; i <= ds.Tables[0].Rows.Count; i++)
            {
                if (((CheckBox)(tblpassinfo.FindControl("chkbx_pass" + i.ToString()))).Checked)
                {
                    count++;
                    Eticket = Eticket + "<Eticket><givenName>" + ds.Tables[0].Rows[i - 1]["FirstName"].ToString() + "</givenName><surName>" + ds.Tables[0].Rows[i - 1]["LastName"].ToString() + "</surName><nameReference>" + ds.Tables[0].Rows[i - 1]["Title"].ToString() + "</nameReference><eticketno>" + ds.Tables[0].Rows[i - 1]["eticketno"].ToString() + "</eticketno><flightuid>" + ds.Tables[0].Rows[i - 1]["flightuid"].ToString() + "</flightuid><passuid>" + ds.Tables[0].Rows[i - 1]["passuid"].ToString() + "</passuid></Eticket>";


                    ViewState["eticketdto"] = "<eticketdto>" + Eticket + "</eticketdto>";
                }
            }

            if (count > 0)
            {
                #region Call Function Send Cancellation Request and Get cancellation details Response --- Call Cancellation STatus Request and Cancellation Status Response
         //       Get_Cancellation_Request_Response();  //send cancellation request first time

                if (DS_Cancellation_Response.Tables.Contains("CancelationDetails"))
                {
                    if (DS_Cancellation_Response.Tables["CancelationDetails"].Rows.Count != 0)
                    {

                        if ((DS_Cancellation_Response.Tables["CancelationDetails"].Columns.Contains("error")))
                        {
                            RegisterClientScriptBlock("alert", "<script>alert('" + Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]) + "');</script>");
                            //  lbl_cancellationResponse.Text = Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]);
                            ViewState["Cancellation_Response_error"] = Convert.ToString(DS_Cancellation_Response.Tables["CancelationDetails"].Rows[0]["error"]);


                        }
                    }
                }

                if (DS_Cancellation_Response.Tables.Contains("onwardcanceldata"))
                {

                    if (DS_Cancellation_Response.Tables["onwardcanceldata"].Rows.Count != 0)
                    {
                        #region Send Cancellation Status Request and Get Cancellation Status Response xml

                        ViewState["Cancellation_id"] = Convert.ToString(DS_Cancellation_Response.Tables["onwardcanceldata"].Rows[0]["Canid"]);
                        ViewState["Cancellation_status"] = Convert.ToString(DS_Cancellation_Response.Tables["onwardcanceldata"].Rows[0]["status"]);

                     //   Get_Cancellation_Status_Request_Response();  //send cancellation request if there is no error tag first time that is request has been send...  and  now send cancellation status request

                        Get_Cancellation_Status_Response_For_UpdateTable();  //read cancel status Pending,Processed,Rejected
                        //read refund status  Pending,Processed


                        //  update  adult child infant ticket status  if cancellation status is pending or processed
                        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_DepartFlight();  //if pending  
                        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response();  //if processed

                        //  insert in  cancellation table insert first time when pending else update when processed
                        Insert_Air_Cancellation_Details_Table_When_Status_Pending();  //if pending
                        Update_Air_Cancellation_Details_Table_when_Status_Processed();  //if processed


                        // if refund status is processes then update in transaction details table about amounts 
                        Update_Air_All_Table_When_Refund_Status_Processed();   //refund


                        #endregion

                    }

                }


                if (DS_Cancellation_Response.Tables.Contains("returncanceldata"))
                {

                    if (DS_Cancellation_Response.Tables["returncanceldata"].Rows.Count != 0)
                    {
                        #region Send Cancellation Status Request and Get Cancellation Status Response xml

                        ViewState["Cancellation_id_Return"] = Convert.ToString(DS_Cancellation_Response.Tables["returncanceldata"].Rows[0]["Canid"]);
                        ViewState["Cancellation_status_Return"] = Convert.ToString(DS_Cancellation_Response.Tables["returncanceldata"].Rows[0]["status"]);

                   //     Get_Cancellation_Status_Request_Response_Return();
                        Get_Cancellation_Status_Response_For_UpdateTable_ReturnFlight();
                        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_When_Cancellation_Status_Response_Pending_For_ReturnFlight();
                        Update_Air_Adult_Child_Infant_Cancel_Ticket_Info_Details_Table_According_To_Cancellation_Status_Response_ReturnFlight();
                        Insert_Air_Cancellation_Details_Table_When_Status_Pending_For_ReturnFlight();
                        Update_Air_Cancellation_Details_Table_when_Status_Processed_for_ReturnFlight();
                        Update_Air_All_Table_When_Refund_Status_Processed_ReturnFlight();


                        #endregion

                    }

                }



                #endregion
            }
            else
            {
                Page.RegisterStartupScript("XXX", "<script> alert('Please select at least 1 Ticket to Cancel')</script>");

            }
            // Bind_Cancellation_ticket_details();         

            //_________
            flightinfo();
            passinfo(checkforCancellable());
            Response.Redirect("../Transaction/Cancel.aspx");

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