Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in Seat.aspx
The Code is


XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="obout" Namespace="OboutInc.Flyout2" Assembly="obout_Flyout2_NET"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Repeater id="Repeater1" runat="server">

<HeaderTemplate>
<table class="thText"  width="1000px">
<tr>
<th class="tdText" style="font-weight:bold;" align="left" valign="bottom">Travels</th>
<th class="tdText" style="font-weight:bold;" align="left">Bus Types</th>
<%--<th class="tdText" style="font-weight:bold;" align="left">Amenities</th>--%>
<th class="tdText" style="font-weight:bold;" align="left">Departure</th>
<th class="tdText" style="font-weight:bold;" align="left">Seats</th>
<th class="tdText" style="font-weight:bold;" align="left">availableTrips_fares</th>
<th class="tdText" style="font-weight:bold;" align="left">mTicketEnabled</th>
</tr>
</HeaderTemplate>

<ItemTemplate>

<tr>

    <td class="tdText"><%# Eval("Travels")%></td>
    <td class="tdText"><%# Eval("busType")%></td>
    <%--<td class="tdText"><%# Eval("Amenities")%></td>--%>

    <td class="tdText">

        <asp:LinkButton ID="Button1" Text='<%# Eval("departureTime")%>' runat="server" />

        <obout:Flyout ID="Flyout1" runat="server" AttachTo="Button1"   Position="MIDDLE_RIGHT" Align="TOP">
            <div style="width:200px; background-color:lightblue">
                    <table>
                        <tr>
                            <td class="tdText"><b></b></td>
                            <td class="tdText"> <%# Eval("availableTrips_boardingTimes")%></td>
                        </tr>


                    </table>


            </div>
        </obout:Flyout>
        <br />

         <asp:LinkButton ID="LinkButton1" Text='<%# Eval("arrivalTime")%>' runat="server" />
        <obout:Flyout ID="Flyout2" runat="server" AttachTo="LinkButton1" Position="MIDDLE_RIGHT" Align="TOP">

            <div style="width:200px; background-color:lightblue">
                    <table>
                        <tr>
                            <td class="tdText"><b></b></td>
                            <td class="tdText"> <%# Eval("availableTrips_droppingTimes")%></td>
                        </tr>
                        </table>


            </div>
            </obout:Flyout>


    </td>
    <td class="tdText">  <%# Eval("availableSeats")%></td>
   <td class="tdText">    <%# Eval("availableTrips_fares")%></td>
    <td class="tdText"><%# Eval("mTicketEnabled")%>

      <table>
        <tr>
         <td>
          <asp:Button ID="btnview" runat="server" Text="View seats" ForeColor="#990000" BackColor="#CCCCCC" OnClick="btnview_Click"/>

         </td>
        </tr>
      </table>
    </td>
</tr>


</ItemTemplate>
<SeparatorTemplate>
 <tr style="border-bottom-style: inset; border-bottom-width: medium; border-bottom-color: #000000">
                   <td>
                      <hr />
                   </td>
                   <td>
                       <hr />
                   </td>
                   <td>

                       <hr />
                   </td>
                   <td>
                       <hr />
                   </td>
                   <td>
                       <hr />
                   </td>
                   <td>
                       <hr />
                   </td>
               </tr>

</SeparatorTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
 </div>
    </form>
</body>




in Seat.aspx.cs




using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PSL.SS;
using Model;
using Newtonsoft.Json;
using System.Text;
using System.Collections;
using System.Data;
using System.Xml;
using APICore;
using Newtonsoft;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Linq;
using System.IO;


public partial class _Default : System.Web.UI.Page
{
    private static string baseUrl = "http://api.seatseller.travel";
    private static string consumerKey = "xyz";
    private static string consumerSecret = "xyz";




    

    SSAPIClient client1 = new SSAPIClient("http://api.seatseller.travel", consumerKey, consumerSecret);

    
    //jaipur=3947
    //delhi=1647
    //Agra=3994
    //mumbai=7
    //Goa=3689


    private string source = "2"; //Bangalore
    private string destination = "2838"; //Mangalore
    private string doj = "2012-08-25";


    string sourceId, Destinationid, Dateofjourney, TripId;

    public string TripId1
    {
        get { return TripId; }
        set { TripId = value; }
    }
    public string Dateofjourney1
    {
        get { return Dateofjourney; }
        set { Dateofjourney = value; }
    }

    public string Destinationid1
    {
        get { return Destinationid; }
        set { Destinationid = value; }
    }

    public string SourceId
    {
        get { return sourceId; }
        set { sourceId = value; }
    }
    //public Comparison<Seat> compareSeatColumnPosition
    //{
    //{ get; set; }
    //}
    private void GetSourceList()
    {
        APIBase APIbase = new APIBase();
        DataTable dt = (APIbase.GetAvailableTrips("3", "6", "2013-11-05")).Tables[0];
       // DataSet ds = (APIbase.GetTripDetails(tripId));
        //DataTable dt = (APIbase..Tables[0];
        Repeater1.DataSource = dt;
        Repeater1.DataBind();

    }

    //public string getFirstTripId()
    //{
    //    string getAvailablityString = A.getAvailableTrips(source, destination, doj);
    //    AvailableTripList deserializedGetAvailablityString = JsonConvert.DeserializeObject<AvailableTripList>(getAvailablityString);
    //    string firstTripId = deserializedGetAvailablityString.AvailableTrips[0].Id.ToString();

    //    return firstTripId;

    //}
    private DataSet convertJsonStringToDataSet(string jsonString)
    {
        XmlDocument xd = new XmlDocument();
        jsonString = "{ \"rootNode\": {" + jsonString.Trim().TrimStart('{').TrimEnd('}') + "} }";
        xd = (XmlDocument)JsonConvert.DeserializeXmlNode(jsonString);
        DataSet ds = new DataSet();
        ds.ReadXml(new XmlNodeReader(xd));
        return ds;

    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           // GetSourceList();
            convertJsonStringToDataSet();
        }
    }

    static int compareSeatColumnPosition(Seat s1, Seat s2)
    {
        return s1.Column.CompareTo(s2.Column);
    }

    public string getFirstTripId()
    {
        string getAvailablityString = client1.getAvailableTrips(source, destination, doj);
       
        AvailableTripList deserializedGetAvailablityString = JsonConvert.DeserializeObject<AvailableTripList>(getAvailablityString);
        string firstTripId = deserializedGetAvailablityString.AvailableTrips[0].Id.ToString();

        return firstTripId;

    }

    protected void btnview_Click(object sender, EventArgs e)
    {
        convertJsonStringToDataSet();
        //string tripId = getFirstTripId();
        //if (tripId.Equals("NO_RECORD_FOUND"))
        //{
        //    Response.Write("Please change the source destination and DOJ and try with the method, getFirstTripId");
        //    return;
        //}

    }
   protected string tripId = "100000110390000431";

    private DataSet convertJsonStringToDataSet()
    {

        APIBase APIbase = new APIBase();
        XmlDocument xd = new XmlDocument();
        DataSet ds = new DataSet();
        string ds111 = APIbase.GetTripDetails(tripId);
        var seatObject = JObject.Parse(ds111);
        List<SeatLayout> LstSeatLayout = new List<SeatLayout>();
        foreach (var item in seatObject["seats"])
        {
            SeatLayout seatLayout = new SeatLayout();
            seatLayout.RowId = item["row"].ToString();
            seatLayout.ColumnID = item["column"].ToString();
            seatLayout.Name = item["name"].ToString();
            seatLayout.Fare = item["fare"].ToString();
            seatLayout.LadiesSeat = item["ladiesSeat"].ToString();
            seatLayout.Length = item["length"].ToString();
          
            LstSeatLayout.Add(seatLayout);
        }
        ds = convertJsonStringToDataSet(ds111);
        return ds;
    }
    protected void btnview_Click(object sender, EventArgs e)
    {

       

        if (tripId.Equals("NO_RECORD_FOUND"))
        {
            Response.Write("Please change the source destination and DOJ and try with the method, getFirstTripId");
            return;
        }


        string requestUrl = "http://api.seatseller.travel/tripdetails?id=" + tripId;
        string getAvailableTripsreturnedstring = client1.getTripDetails(tripId);
        TripDetails seatListRetrievedFromAPI = JsonConvert.DeserializeObject<TripDetails>(getAvailableTripsreturnedstring);
        SortedDictionary<string, List<Seat>> seat2DRep = new SortedDictionary<string, List<Seat>>();
        foreach (Seat eachSeat in seatListRetrievedFromAPI.Seats)
        {
            if (!seat2DRep.ContainsKey(eachSeat.Row))
            {
                seat2DRep.Add(eachSeat.Row, new List<Seat>());
                
            }
            seat2DRep[eachSeat.Row].Add(eachSeat);
        }
        StringBuilder seatLayoutHtml = new StringBuilder();
        seatLayoutHtml.Append("<table  border=1 cellpadding=5 cellspacing=5 width=100%>");
        Comparison<Seat> seatColumnPositionComparator = new Comparison<Seat>(compareSeatColumnPosition); 
              
        foreach (String rowNumber in seat2DRep.Keys)
        {
            //sort each row to have the seats in order
            seat2DRep[rowNumber].Sort(seatColumnPositionComparator);

            seatLayoutHtml.Append("<tr width=100% >");
            foreach (Seat eachSeat in  [rowNumber])//iterate through all the seats in that row
            {
                string tdColspan = Convert.ToString(Convert.ToInt32(eachSeat.Length));//(eachSeat.seatSpec.width));

                seatLayoutHtml.Append("<td colspan=" + tdColspan + " align='right'>");
                // seatLayoutHtml.Append("<input type=CheckBox id='chk");
                seatLayoutHtml.Append(eachSeat.Name + "' ");
                seatLayoutHtml.Append("value='" + eachSeat.Name + "' ");
                if (eachSeat.Available == "true") //(eachSeat.available)
                {
                    seatLayoutHtml.Append(" önClick=//////javascript://selChanged(this) >");
                }
                else
                {
                    seatLayoutHtml.Append("style='display:none;'> ");
                }
                seatLayoutHtml.Append(eachSeat.Name + "<br/> (Rs." + eachSeat.Fare + ")");
                seatLayoutHtml.Append("</input>");
                seatLayoutHtml.Append("</td>");
                //tdId = Convert.ToInt32(eachSeat.Width)+Convert.ToInt32(eachSeat.Column);
            }
            seatLayoutHtml.Append("</tr>");
            //trId = trId + 1;
        }


        seatLayoutHtml.Append("</table>");
        //seatLayoutDiv.InnerHtml = seatLayoutHtml.ToString();
    }






}

//}
</html>


in bin folder i added these dll files

APICore.dll
APICore.pdb
DevDefined.OAuth.dll
Newtonsoft.Json.dll
psl.api.ssapi.SSAPICore.dll
psl.api.ssapi.SSAPICore.pdb
SSAPIClient.pdb
Telerik.Web.UI.dll
Telerik.Web.UI.xml


i tried above code in this way, but iam not getting the output(SeatLayout) please help me in this code, iam in need of this code, waitng for reply thanks in advance
Posted

1 solution

hello sir,

i am created online bus booking same pbroblem for u
any helpand any idea

my mail id=rrji.renga@gmail.com

waiting for u valuble replay

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900