protected void SearchHotelButton_Click(object sender, EventArgs e) { try { int roomNo = int.Parse(NoOfRooms.Text); HRSHotelsBLL hotelBLLObject = new HRSHotelsBLL(); HRSBookingsBLL bookingBLLObject = new HRSBookingsBLL(); string roomType = RoomTypeDropDownList.SelectedItem.Text; var hotels = hotelBLLObject.SearchHotels(roomNo, CityDropDownList.SelectedItem.Text, roomType); foreach (var hotel in hotels) { var bookingRD = bookingBLLObject.GetBookingsByHotelID(hotel.HotelID); foreach (var booking in bookingRD) { DateTime queryArrivalDate = DateTime.Parse(CheckInTextBox.Text); DateTime queryDepartureDate = DateTime.Parse(CheckOutTextBox.Text); if (booking.ArrivalDate <= queryDepartureDate && queryArrivalDate <= booking.DepartureDate) { if (booking.RoomType == Utility.HRSConstants.AC) { hotel.NoOfACRooms -= booking.TotalRooms; } else { hotel.NoOfNACRooms -= booking.TotalRooms; } } } if (roomType == Utility.HRSConstants.AC) { if (hotel.NoOfACRooms < roomNo) { hotels.Remove(hotel); } } else { if (hotel.NoOfNACRooms < roomNo) { hotels.Remove(hotel); } } } if (hotels.Count >= 1) { SearchHotelResult.DataSource = hotels; SearchHotelResult.DataBind(); HiddenTable.Visible = true; HiddenLabel.Visible = false; } else { ErrorLabel.Text = "Search Found No Relevant Results"; HiddenTable.Visible = false; HiddenLabel.Visible = true; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$(function () {"); sb.Append(" $('#Result').modal('show');});"); sb.Append("</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModelScript", sb.ToString(), false); } catch (Exception ex) { Utility.ExceptionUtility.ExceptionLog(ex); throw; } }
public CheckAvailabilityForTs() { HodelData = new SearchHotelResult(); roomResults = new List <SearchRoomResult>(); }