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