protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); var hotelIds = hotelsBLLObject.GetHotelsID(); HotelIDDropDownList.DataSource = hotelIds; HotelIDDropDownList.DataTextField = "Value"; HotelIDDropDownList.DataValueField = "Key"; HotelIDDropDownList.DataBind(); BookingDateTextbox.Text = DateTime.Now.ToString("MM/dd/yyyy"); NoOfNightsTextBox.Text = string.Empty; HotelIDDropDownList.SelectedValue = Request.QueryString["field"]; } if (IsPostBack) { if (ArrivalDateTextBox.Text != "" && DepartureDateTextbox.Text != "") { DateTime arrivalDate = DateTime.Parse(ArrivalDateTextBox.Text.ToString()); DateTime departureDate = DateTime.Parse(DepartureDateTextbox.Text.ToString()); int noOfNights = (int)(departureDate - arrivalDate).TotalDays; NoOfNightsTextBox.Text = noOfNights.ToString(); } } ArrivalDateTextBox.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); DepartureDateTextbox.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); } catch (Exception ex) { Utility.ExceptionUtility.ExceptionLog(ex); throw; } }
protected void HotelSearchButton_Click(object sender, EventArgs e) { try { HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); string hotelID = HotelIDDropDownList.SelectedItem.Value; Hotel hotel = hotelsBLLObject.GetHotelDetailsByID(hotelID); HotelIDLabel.Text = hotelID; if (hotel != null) { CountryLabel.Text = hotel.Country; HotelNameLabel.Text = hotel.HotelName; CityLabel.Text = hotel.City; HotelDescriptionLabel.Text = hotel.HotelDescription; NoOfACRoomsLabel.Text = hotel.NoOfACRooms.ToString(); NoOfNACRoomsLabel.Text = hotel.NoOfNACRooms.ToString(); RateAdultTextBox.Text = hotel.RateAdultACRoom.ToString(); RateChildTextBox.Text = hotel.RateChildACRoom.ToString(); RateNACChildTextBox.Text = hotel.RateChildNACRoom.ToString(); RateNACAdultTextBox.Text = hotel.RateAdultNACRoom.ToString(); TotalRoomLabel.Text = (hotel.NoOfACRooms + hotel.NoOfNACRooms).ToString(); } hidden.Visible = true; } catch (Exception ex) { Utility.ExceptionUtility.ExceptionLog(ex); throw; } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); string hotelID = HotelIDDropDownList.SelectedItem.Value; int result = hotelsBLLObject.DeleteHotelDetails(hotelID); if (result > 0) { ErrorMessageLabel.Text = "Data Deleted Successfully"; } else { ErrorMessageLabel.Text = "Failed"; } 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; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (!Session["userId"].ToString().EndsWith(Utility.HRSConstants.ADMINENDSTRING)) { FormsAuthentication.SignOut(); Session.Clear(); } HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); var HotelIds = hotelsBLLObject.GetHotelsID(); HotelIDDropDownList.DataSource = HotelIds; HotelIDDropDownList.DataTextField = "Value"; HotelIDDropDownList.DataValueField = "Key"; HotelIDDropDownList.DataBind(); } hidden.Visible = false; } catch (Exception ex) { Utility.ExceptionUtility.ExceptionLog(ex); throw; } }
protected void BookingIDButton_Click(object sender, EventArgs e) { try { int noOfAdults = 0, noOfChildren = 0, noOfnights = 0, rateAdult = 0, rateChild = 0; double bill = 0; string hotelID = string.Empty; string roomType = string.Empty; HRSBookingsBLL bookingBLLObject = new HRSBookingsBLL(); string bookingID = BookingIDDropDownList.SelectedItem.Text; var booking = bookingBLLObject.GetBookingDetails(bookingID); if (booking != null) { hotelID = booking.HotelID; noOfAdults = booking.NoOfAdults; noOfChildren = booking.NoOfChildren; noOfnights = booking.NoOfNights; roomType = booking.RoomType; } HRSHotelsBLL hotelBLLObject = new HRSHotelsBLL(); var hotel = hotelBLLObject.GetHotelDetailsByID(hotelID); if (roomType == HRSConstants.AC) { rateAdult = hotel.RateAdultACRoom; rateChild = hotel.RateChildACRoom; } else { rateAdult = hotel.RateAdultNACRoom; rateChild = hotel.RateChildNACRoom; } bill = (noOfAdults * rateAdult + noOfChildren * rateChild) * noOfnights; if (noOfnights > 5) { bill = bill - bill * 0.025; } AmountTextBox.Text = bill.ToString(); hidden.Visible = true; } catch (Exception ex) { ExceptionUtility.ExceptionLog(ex); throw; } }
protected void SubmitButton_Click(object sender, EventArgs e) { try { HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); Hotel hotel = new Hotel(); hotel.HotelName = HotelNameTextbox.Text; hotel.Country = CountryDropDownList.SelectedItem.Text; hotel.City = CityDropDownList.SelectedItem.Text; hotel.HotelDescription = HotelDescriptionTextBox.Text; hotel.NoOfACRooms = Convert.ToInt32(NoOfACRoomsTextBox.Text); hotel.NoOfNACRooms = Convert.ToInt32(NoOfNACRoomsTextBox.Text); hotel.RateAdultACRoom = Convert.ToInt32(RateACAdultTextBox.Text); hotel.RateChildACRoom = Convert.ToInt32(RateACChildTextBox.Text); hotel.RateAdultNACRoom = Convert.ToInt32(RateNACAdultTextBox.Text); hotel.RateChildNACRoom = Convert.ToInt32(RateNACChildTextBox.Text); string hotelID = hotelsBLLObject.AddHotelDetails(hotel); if (!string.IsNullOrEmpty(hotelID)) { string display = "Hotel Added Successfully." + "\n" + "Hotel ID: " + hotelID; ErrorMessageLabel.Text = display; } else { ErrorMessageLabel.Text = "failed"; } 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) { ExceptionUtility.ExceptionLog(ex); throw; } }
protected void SaveButton_Click(object sender, EventArgs e) { try { HRSHotelsBLL hotelsBLLObject = new HRSHotelsBLL(); Hotel hotel = new Hotel(); hotel.HotelID = HotelIDDropDownList.SelectedItem.Value; hotel.HotelName = HotelNameEditTextbox.Text; hotel.HotelDescription = HotelDescriptionTextBox.Text; hotel.NoOfACRooms = Convert.ToInt32(NoOfACRoomsTextBox.Text); hotel.NoOfNACRooms = Convert.ToInt32(NoOfNACRoomsTextBox.Text); hotel.RateAdultACRoom = Convert.ToInt32(RateACAdultTextBox.Text); hotel.RateChildACRoom = Convert.ToInt32(RateACChildTextBox.Text); hotel.RateAdultNACRoom = Convert.ToInt32(RateNACAdultTextBox.Text); hotel.RateChildNACRoom = Convert.ToInt32(RateNACChildTextBox.Text); int result = hotelsBLLObject.UpdateHotelDetails(hotel); if (result > 0) { ErrorMessageLabel.Text = "Data Updated Successfully"; } else { ErrorMessageLabel.Text = "Failed"; } 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; } }
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; } }