PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/Veerabook/Default.aspx.cs

https://bitbucket.org/veerabooking/veerabooking
C# | 188 lines | 141 code | 40 blank | 7 comment | 18 complexity | a0357ae693f65e9a4cafbae4204dc318 MD5 | raw file
  1using System;
  2using System.Collections.Generic;
  3using System.Configuration;
  4using System.IO;
  5using System.Linq;
  6using System.Net;
  7using System.Text;
  8using System.Web;
  9using System.Web.UI;
 10using System.Web.UI.WebControls;
 11using System.Data;
 12using System.Data.SqlClient;
 13using System.Text.RegularExpressions;
 14using Newtonsoft.Json.Linq;
 15using Newtonsoft.Json;
 16using System.Xml.Linq;
 17
 18
 19namespace Veerabook
 20{
 21
 22
 23
 24    public partial class Default : System.Web.UI.Page
 25    {
 26
 27        Xtools xtools = new Xtools();
 28        Multi multi = new Multi();
 29
 30
 31        protected string roomStr;
 32        protected string roomsStr;
 33        protected string txtChldAge;
 34        protected string txtChldStr;
 35        protected string txtAdltStr;
 36        protected string AdltCount;
 37        private object childAge1;
 38
 39        protected void Page_Load(object sender, EventArgs e)
 40        {
 41          
 42
 43            if (!IsPostBack)
 44            {
 45
 46                string today = DateTime.Now.ToString("yyyy-MM-dd");
 47                DateTime endDate = Convert.ToDateTime(today);
 48                Int64 addedDays = Convert.ToInt64(2);
 49                endDate = endDate.AddDays(addedDays);
 50                string end = endDate.ToString("yyyy-MM-dd");
 51                startDate.Text = "From " + today + " To " + end;
 52                chckIn.Text = today;
 53                chckOut.Text = end;
 54            }
 55        }
 56
 57        protected void login()
 58        {
 59
 60            Session["SessionId"] = multi.GetLoginsession();
 61
 62        }
 63
 64        protected void btnSearchHotel_Click(object sender, EventArgs e)
 65        {
 66            login();
 67            searchData();
 68
 69            Response.Redirect("HotelListing.aspx");
 70
 71        }
 72
 73        private void searchData()
 74        {
 75            ListView newLvRooms = (ListView)lvRooms;
 76            int x = 0;
 77            foreach (ListViewItem item in newLvRooms.Items)
 78            {
 79
 80                //ListViewItem pnlRoom = newLvRooms.FindControl("pnlRoom") as ListViewItem;
 81                ListViewItem pnlRoom = newLvRooms.Items[x] as ListViewItem;
 82
 83                TextBox txtAdultNum = (TextBox)pnlRoom.FindControl("adltNum");
 84                AdltCount += " Room" + (x + 1) + " = " + txtAdultNum.Text + " , ";
 85                txtAdltStr = "<RoomType>" + txtAdultNum.Text + "</RoomType>";
 86                TextBox txtChildNum = (TextBox)pnlRoom.FindControl("childNum");
 87                txtChldAge = null;
 88                if (int.Parse(txtChildNum.Text) > 0)
 89                {
 90                    for (int i = 0; i < int.Parse(txtChildNum.Text); i++)
 91                    {
 92                        string chldAgeID = "childAge" + (i + 1);
 93                        TextBox txtChildAge = (TextBox)pnlRoom.FindControl(chldAgeID);
 94                        txtChldAge += "<Age>" + txtChildAge.Text + "</Age>";
 95                    }
 96                    txtChldStr = "<Children>" + txtChldAge + "</Children>";
 97                }
 98                roomStr += "<Room>" + txtAdltStr + txtChldStr + "</Room>";
 99                x++;
100            }
101            roomsStr = "<Rooms>" + roomStr + "</Rooms>";
102
103            string postData ="<RequestHeader><LoginName>" + multi.LoginName + "</LoginName><SessionId>" + Session["SessionId"].ToString() + "</SessionId><Language>en</Language><AsyncMode>FALSE</AsyncMode></RequestHeader><SearchData><Hotel><Destination><CityCode></CityCode><CityName>" + txtDestinations.Text + "</CityName></Destination><CheckIn>" + chckIn.Text + "</CheckIn><CheckOut>" + chckOut.Text + "</CheckOut>" + roomsStr + "<Category></Category></Hotel></SearchData>";
104            Session["sessionNumAdlts"] = AdltCount;
105            Session["htlSrchPostData"] = postData;
106            Session["checkIn"] = chckIn.Text;
107            Session["checkOut"] = chckOut.Text;
108        }
109
110        protected void ddlNoRooms_SelectedIndexChanged(object sender, EventArgs e)
111        {
112            DataSet ds = new DataSet();
113            DataTable dt = new DataTable("dt");
114            dt.Columns.Add("ID");
115            for (int i = 0; i < int.Parse(ddlNoRooms.SelectedValue.ToString()); i++)
116            {
117                // TRY LISTVIEW TO LOOP ON ROOM DATA
118                DataRow dr = dt.NewRow();
119                dr[0] = i.ToString();
120                dt.Rows.Add(dr);
121            }
122
123            ds.Tables.Add(dt);
124            lvRooms.DataSource = ds;
125            lvRooms.DataBind();
126            Session["sessionNumRooms"] = ddlNoRooms.SelectedValue.ToString();
127        }
128
129
130
131      
132        protected void fillRoomStr()
133        {
134
135        }
136
137        protected void startDate_TextChanged(object sender, EventArgs e)
138        {
139
140        }
141        protected void childNum_TextChanged(object sender, EventArgs e)
142        {
143            TextBox txtChildNum = (TextBox)sender;
144            int txtChildnum;
145            if (txtChildNum.Text.Trim() == "" || txtChildNum.Text == null)
146            {
147                txtChildnum = 0;
148            }
149            else
150            {
151                txtChildnum = int.Parse(txtChildNum.Text);
152
153            }
154
155            // Get the container panel
156            //Panel pnlRoom = (Panel)txtChildNum.NamingContainer;
157            ListViewDataItem pnlRoom = (ListViewDataItem)(sender as Control).NamingContainer;
158
159            // find number of adults
160            // TextBox Child_1 = (TextBox)pnlRoom.FindControl("childNum0");
161
162            // add number of kids
163            for (int j = 0; j < txtChildnum; j++)
164            {
165                string chldID = "childAge" + (j + 1);
166                TextBox Child_txt = (TextBox)pnlRoom.FindControl(chldID);
167                Child_txt.Enabled = true;
168
169                if (Page.IsPostBack && "childAge1" != string.Empty)
170                {
171                    Child_txt.Visible = false;
172
173                }
174                if (Page.IsPostBack && "childAge2" != string.Empty)
175                {
176                    Child_txt.Visible = false;
177
178                }
179                if (Page.IsPostBack && "childAge3" != string.Empty)
180                {
181                    Child_txt.Visible = false;
182
183                }
184
185            }
186        }
187    }
188}