private void detach_ReservationDetails(ReservationDetail entity)
		{
			this.SendPropertyChanging();
			entity.Discount = null;
		}
 partial void DeleteReservationDetail(ReservationDetail instance);
		private void attach_ReservationDetails(ReservationDetail entity)
		{
			this.SendPropertyChanging();
			entity.Room = this;
		}
 partial void UpdateReservationDetail(ReservationDetail instance);
 partial void InsertReservationDetail(ReservationDetail instance);
        protected void btnReserve_Click(object sender, EventArgs e)
        {
            if (gvRoomInfo.Rows.Count > 0)
            {
                TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext();
                Reservation res = new Reservation();

                res.GuestID = reserving.GuestID;
                res.ReservationDate = DateTime.Today;
                res.ReservationStatus = 'U';
                db.Reservations.InsertOnSubmit(res);
                db.SubmitChanges();

                LinkedList<RoomInfo> ri = (LinkedList<RoomInfo>)Session["RoomIDs"];
                int i = 0;
                foreach(RoomInfo r in ri)
                {
                    ReservationDetail resDetail = new ReservationDetail();
                    gvRoomInfo.SelectRow(i);
                    resDetail.ReservationID = res.ReservationID;
                    resDetail.CheckinDate = Convert.ToDateTime(reserving.reserveDate);
                    resDetail.RoomID = Convert.ToInt16(r.RoomID);
                    resDetail.QuotedRate = Convert.ToByte(reserving.daysStaying) * Convert.ToDecimal(gvRoomInfo.SelectedRow.Cells[2].Text);
                    resDetail.ReservationStatus = 'A';
                    resDetail.Nights = Convert.ToByte(reserving.daysStaying);
                    DropDownList ddl = (DropDownList) gvRoomInfo.SelectedRow.Cells[3].FindControl("numAdults");
                    resDetail.NumberOfAdults = Convert.ToByte(ddl.SelectedValue);
                    ddl = (DropDownList)gvRoomInfo.SelectedRow.Cells[4].FindControl("numChild");
                    resDetail.NumberOfChildren = Convert.ToByte(ddl.SelectedValue);
                    resDetail.DiscountID = 1;
                    db.ReservationDetails.InsertOnSubmit(resDetail);
                    db.SubmitChanges();
                    i++;
                }

                lblFinalReservationNumber.Text = res.ReservationID.ToString();

                db = new TreasureLandDataClassesDataContext();
                var resing = from  rv in db.Reservations
                               join rd in db.ReservationDetails
                               on rv.ReservationID equals rd.ReservationID
                               join ro in db.Rooms
                               on rd.RoomID equals ro.RoomID
                               join hrt in db.HotelRoomTypes
                               on ro.HotelRoomTypeID equals hrt.HotelRoomTypeID
                               where rv.ReservationID == Convert.ToInt16(lblFinalReservationNumber.Text)
                               select new { rd.ReservationDetailID, ro.RoomNumbers, rd.CheckinDate, hrt.RoomType };
                gvReserved.DataSource = resing.ToList();
                gvReserved.DataBind();

                reserving.returnView = 4;
            }
            else
            {
                lblError.Text = "Please select a room before commting a reservation";
            }
        }