protected void btnAddRoomType_Click(object sender, EventArgs e) { roomTypeHandler = new RoomTypeHandler(); string option = ""; double num = 0; option = txtRate.Text.Trim(); if (double.TryParse(option, out num) == true) { RoomType roomType = new RoomType(); roomType.TypeID = Convert.ToInt32(lblTypeID.Text.Trim()); roomType.Name = txtName.Text; roomType.MaxCapacity = Convert.ToInt32(txtRoomTypeCapacity.Text.Trim()); roomType.RatePerNight = Convert.ToDouble(txtRate.Text.Trim()); roomTypeHandler.UpdateRoomType(roomType); lblProgress.Text = "Room edited successfully."; //delay redirect to alert user of page change lblRedirect.Text = "Redirecting to room type list in 5 seconds."; Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"ViewRoomTypes.aspx\"; }, 5000);</script>"); } else if (double.TryParse(option, out num) == false) { lblRoomTypeRateIsNumberValidator.Visible = true; } else if (txtRate.Text == null) { lblRoomTypeRateIsNumberValidator.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { roomTypeHandler = new RoomTypeHandler(); if (IsPostBack == false) { rdoAvailable.Checked = true; BindData(); } }
protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Session["EditRoomType"]); roomTypeHandler = new RoomTypeHandler(); RoomType roomType = roomTypeHandler.GetRoomTypeDetails(id); lblRoomTypeID.Text = id.ToString(); lblRoomTypeName.Text = roomType.Name.ToString(); lblRoomTypeCapacity.Text = roomType.MaxCapacity.ToString(); lblRatePerNight.Text = roomType.RatePerNight.ToString(); }
protected void Page_Load(object sender, EventArgs e) { //Populate room type drop down list if (!IsPostBack) { RoomTypeHandler roomTypeHandler = new RoomTypeHandler(); List<RoomType> listRoomTypes = roomTypeHandler.GetRoomTypeList(); ddlRoomType.DataSource = listRoomTypes; ddlRoomType.DataValueField = "TypeID"; ddlRoomType.DataTextField = "Name"; ddlRoomType.DataBind(); ddlRoomType.Items.Insert(0, new ListItem("Select Room Type", "NA")); } DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); try { startDate = (DateTime)Session["StartDate"]; endDate = (DateTime)Session["EndDate"]; } catch (NullReferenceException) { Response.Redirect("Availability.aspx"); } litHeader.Text = "<h3>Rooms available between " + startDate.Year + "-" + startDate.Month + "-" + startDate.Day + " and " + endDate.Year + "-" + endDate.Month + "-" + endDate.Day + "</h3>"; int roomID = 0; string htmlOutput = ""; string picture = ""; AvailabilityHandler availabilityHandler = new AvailabilityHandler(); List<RoomAndType> listRoomAvailability = availabilityHandler.GetListOfAllRooms(); //Check to make sure there is rooms in the system if (listRoomAvailability == null) litHeader.Text = "<h3>There are currently no rooms added to the system</h3>"; else { for (int i = 0; i < listRoomAvailability.Count; i++) { roomID = listRoomAvailability[i].RoomID; if (listRoomAvailability[i].Picture != null && listRoomAvailability[i].Picture != "") picture = "<a href=\"" + "." + listRoomAvailability[i].Picture.Replace('\\', '/') + "\" data-lightbox=\"image" + i.ToString() + "\">View Picture</a>"; else picture = "No Picture Available"; if (availabilityHandler.CheckAvailability(roomID, startDate, endDate) == true) htmlOutput += "<tr><td>" + listRoomAvailability[i].RoomNo.ToString() + "</td><td>" + listRoomAvailability[i].Name + "</td><td>" + picture + "</td><td>" + listRoomAvailability[i].MaxCapacity.ToString() + "</td><td>R " + listRoomAvailability[i].Rate.ToString() + "</td><td><input type=\"button\" value=\"View\" onclick=\"window.open('RoomDetails.aspx?id=" + listRoomAvailability[i].RoomID + "', 'name', 'height=270,width=270')\" /></td><td><input type=\"checkbox\" onclick=\"AddRoomToBooking(" + listRoomAvailability[i].RoomID + ")\" />" + "</td></tr>\n"; } litAvailableRooms.Text = htmlOutput; } }
protected void btnAddRoomType_Click(object sender, EventArgs e) { handler = new RoomTypeHandler(); int rateId = 0; string option = ""; double num = 0; option = txtRatePerNight.Text; if (double.TryParse(option, out num) == true && handler.ValidateRoomTypeName(txtRoomTypeName.Text) == false && double.TryParse(option, out num) == true) { RoomType roomType = new RoomType(); roomType.Name = txtRoomTypeName.Text; roomType.MaxCapacity = int.Parse(txtRoomTypeCapacity.Text); roomType.RatePerNight = Convert.ToDouble(txtRatePerNight.Text); handler.AddNewRoomType(roomType); rateId = handler.GetLastRoomTypeID(); handler.AddNewRate(Convert.ToDouble(txtRatePerNight.Text), rateId); Response.Redirect("ViewRoomTypes.aspx"); } if (handler.ValidateRoomTypeName(txtRoomTypeName.Text) == false) { DuplicateNameValidator.Visible = false; } if (handler.ValidateRoomTypeName(txtRoomTypeName.Text) == true) { DuplicateNameValidator.Visible = true; } if (txtRoomTypeName == null) { DuplicateNameValidator.Visible = false; } if (double.TryParse(option, out num) == false) { lblRoomTypeRateIsNumberValidator.Visible = true; } if (double.TryParse(option, out num) == true) { lblRoomTypeRateIsNumberValidator.Visible = false; } if (txtRatePerNight.Text == null) { lblRoomTypeRateIsNumberValidator.Visible = false; } }
protected void BindData() { DateTime todaysDate = DateTime.Now.AddDays(1); userInput = TextBox1.Text; RoomTypeHandler handler = new RoomTypeHandler(); string htmlOutput = ""; List<Booking> occupantList = handler.GetOccupants(userInput, todaysDate); try { for (int i = 0; i < occupantList.Count; i++) { //room name list string roomNames = ""; string roomNumbers = occupantList[i].RoomsBooked; string[] roomlist; string arriveDate = ""; string departDate = ""; roomlist = roomNumbers.Split(','); for (int x = 0; x < roomlist.Length; x++) { arriveDate = occupantList[i].ArriveDate.Year.ToString() + '-' + occupantList[i].ArriveDate.Month.ToString() + '-' + occupantList[i].ArriveDate.Day.ToString(); departDate = occupantList[i].DepartDate.Year.ToString() + '-' + occupantList[i].DepartDate.Month.ToString() + '-' + occupantList[i].DepartDate.Day.ToString(); roomNames += handler.GetRoomNames(roomlist[x]) + " "; } htmlOutput += "<tr><td>" + occupantList[i].BookingID + "</td><td>" + arriveDate + "</td><td>" + departDate + "</td><td>" + occupantList[i].FullName + "</td><td>" + roomNames + "</td><td><a class=\"btn btn-info\" href = \"Profile.aspx?id=" + occupantList[i].MemberID.ToString() + "\">View Profile</a></td></tr>"; roomNames = ""; } } catch (NullReferenceException) { htmlOutput = "<tr><td colspan=\"6\" style=\"text-align:center; font-size:20px; font-wight:bold; color:red;\">There no occupied rooms</td></tr>"; } litOccupantList.Text = htmlOutput; }
protected void Page_Load(object sender, EventArgs e) { lblRoomTypeRateIsNumberValidator.Visible = false; int ID = Convert.ToInt32(Session["EditRoomType"]); if (IsPostBack == false) { roomTypeHandler = new RoomTypeHandler(); RoomType roomType = roomTypeHandler.GetRoomTypeDetails(ID); lblTypeID.Text = ID.ToString(); txtName.Text = roomType.Name.ToString(); txtRoomTypeCapacity.Text = roomType.MaxCapacity.ToString(); txtRate.Text = roomType.RatePerNight.ToString(); } }