protected void Page_Load(object sender, EventArgs e)
        {
            #region Initializing Data

            if (!IsPostBack)
            {
                reserving.roomID = -1;
                reserving.view = 0;

                //Initial set up of dates for the reservation page
                lblDateToday.Text = DateTime.Today.Date.ToShortDateString();
                calDateFrom.SelectedDate = DateTime.Today.Date;
                lblDateFrom.Text = calDateFrom.SelectedDate.Date.ToShortDateString();

                TreasureLandDataClassesDataContext ab = new TreasureLandDataClassesDataContext();
                //Sets Discounts in drop down list
                var discounts = from d in ab.Discounts
                                where d.DiscountExpiration > DateTime.Today.Date
                                select d;

                ddlDiscounts.DataSource = discounts.ToList();
                ddlDiscounts.DataBind();
            }
            //Changes date based on number of days changed
            lblDateTo.Text = calDateFrom.SelectedDate.Date.AddDays(Convert.ToInt32(ddlNumberOfDays.SelectedValue)).ToShortDateString();
            #endregion Initializing Data

            #region Getting Room

            //Get session roomID for room selection
            reserving = GetRoomNumber();
            if (reserving.roomID != -1)
            {
                if (!IsPostBack)
                {
                    lblResFirstName.Text = reserving.firstName;
                    lblResSurName.Text = reserving.surName;
                    lblResPhone.Text = reserving.phone;
                    ddlNumberOfDays.SelectedIndex = reserving.daysStaying - 1;
                    lblDateFrom.Text = reserving.reserveDate;
                    calDateFrom.SelectedDate = Convert.ToDateTime(reserving.reserveDate);
                    ddlDiscounts.SelectedIndex = reserving.Discount;
                }
                mvReservation.ActiveViewIndex = reserving.returnView;

            }

            else
            {

                mvReservation.ActiveViewIndex = reserving.view;
            }
            #endregion Getting Room

            #region Discount Grid View Control

            if (ddlDiscounts.SelectedIndex > 0)
            {
                TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
                var discount = from d in db.Discounts
                               where d.DiscountID == Convert.ToInt16(ddlDiscounts.SelectedValue)
                               select new { d.DiscountRules, d.DiscountAmount, d.IsPrecentage };
                gvDiscount.DataSource = discount.ToList();
                gvDiscount.DataBind();
                gvDiscount.SelectRow(0);
                adjust = Convert.ToDecimal(gvDiscount.SelectedRow.Cells[1].Text);
                isPercent = ((CheckBox)gvDiscount.SelectedRow.Cells[2].Controls[0]).Checked;
            }
            else
            {
                gvDiscount.DataSource = null;
                gvDiscount.DataBind();
                adjust = 0.00M;
                isPercent = false;
            }
            #endregion Discount Grid View Control

            if (Session["RoomIDs"] != null && !IsPostBack)
            {
                #region Return From Select Room
                if (Session["RoomIDs"] != null)
                    RenderSelectedRoomsList();
                #endregion
                reserving.returnView = 3;
                reserving.view = 3;
            }
            else if (Session["RoomIDs"] != null && IsPostBack)
            {
            foreach (GridViewRow row in gvRoomInfo.Rows)
                {
                    if (adjust == 0)
                    {
                        TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
                        var rackrate = from rr in db.HotelRoomTypes
                                       join ro in db.Rooms
                                       on rr.HotelRoomTypeID equals ro.HotelRoomTypeID
                                       where ro.RoomNumbers == row.Cells[0].Text
                                       select new { rr.RoomTypeRackRate };
                        row.Cells[2].Text = string.Format("{0:0.00}", rackrate.First().RoomTypeRackRate);

                    }

                    if (isPercent)
                    {
                        TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
                        var rackrate = from rr in db.HotelRoomTypes
                                       join ro in db.Rooms
                                       on rr.HotelRoomTypeID equals ro.HotelRoomTypeID
                                       where ro.RoomNumbers == row.Cells[0].Text
                                       select new { rr.RoomTypeRackRate };
                        row.Cells[2].Text = string.Format("{0:0.00}", rackrate.First().RoomTypeRackRate);
                        adjust /= 100;
                        row.Cells[2].Text = Convert.ToString(Convert.ToDecimal(row.Cells[2].Text) * (1-adjust));
                    }
                    else
                    {
                        TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
                        var rackrate = from rr in db.HotelRoomTypes
                                       join ro in db.Rooms
                                       on rr.HotelRoomTypeID equals ro.HotelRoomTypeID
                                       where ro.RoomNumbers == row.Cells[0].Text
                                       select new { rr.RoomTypeRackRate };
                        row.Cells[2].Text = string.Format("{0:0.00}", rackrate.First().RoomTypeRackRate);
                        row.Cells[2].Text = Convert.ToString(Convert.ToDecimal(row.Cells[2].Text) - adjust);
                    }

                    quotedPrice += Convert.ToDecimal(row.Cells[2].Text);

                }

                quotedPrice *= Convert.ToInt16(reserving.daysStaying);

                lblTotalCost.Text = string.Format("{0:0.00}", quotedPrice);

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Room"] != null)
                reserving = (Reserve)Session["Room"];
            else
            {
                reserving = new Reserve();
                Session.Add("Room", reserving);
            }

            if (!IsPostBack)
            {
                reserving.roomID = -1;
                mvUpdateReservation.ActiveViewIndex = reserving.returnView;
                reserving.returnView = 0;
                lblReservationNumber.Text = reserving.roomID.ToString();
            }

            reserving = GetRoomNumber();
        }
        protected void btnSelectRoom_Click(object sender, EventArgs e)
        {
            //Collects data for session and sends to select room page
            Session.Clear();
            reserving = GetRoomNumber();
            reserving.reserveDate = lblDateFrom.Text;
            reserving.daysStaying = Convert.ToInt32(ddlNumberOfDays.SelectedValue);
            reserving.view = 2;
            reserving.returnView = 3;
            reserving.firstName = lblResFirstName.Text;
            reserving.surName = lblResSurName.Text;
            reserving.phone = lblResPhone.Text;
            reserving.Discount = ddlDiscounts.SelectedIndex;

            Response.Redirect("SelectRoom.aspx");
        }