Пример #1
0
        protected void CheckAvailabilitySelectedDates_Click(object sender, EventArgs e)
        {
            if (Session["SelectedDates"] != null)
            {
                //create booking elements for grid view display
                sessionBookingElements = BookingElement.CreateBookingElementsForUserSelectedDates
                                             ((List <DateTime>)Session["SelectedDates"], currentRoomData);
                BookingElement.AddRoomRateByDate(currentRoomData, ref sessionBookingElements);
                BookingElement.AddAvailabilityToBookingElements(ref sessionBookingElements);
                //List<BookingElement> availableBookingElements =
                BookingElement.BookingElementsWithAvailability(ref sessionBookingElements);
                gvAvailability.DataSource = sessionBookingElements;
                gvAvailability.DataBind();
                foreach (GridViewRow row in gvAvailability.Rows)
                {
                    DropDownList dl        = (DropDownList)row.FindControl("ddlUserGuests");
                    int          max       = int.Parse(gvAvailability.Rows[row.RowIndex].Cells[2].Text);
                    int[]        ddlSource = Enumerable.Range(0, max + 1).ToArray();
                    dl.DataSource = ddlSource;
                    dl.DataBind();
                }

                UpdatePanelReturnAvailability.Update();
            }
        }
Пример #2
0
 protected void btnRetrieveBooking_Click(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         lblRetrieveName.Visible         = false;
         lblRetrieveCountry.Visible      = false;
         lblRetrievePhone.Visible        = false;
         lblRetrieveBookingNotes.Visible = false;
         string email = txtRetrieveBookingEmail.Text;
         string id    = txtRetrieveBookingID.Text;
         List <BookingElement> booking = BookingElement.RetrieveBookingDetails(email, id);
         lblRetrieveName.Text            = booking[0].CustomerName;
         lblRetrieveCountry.Text         = booking[0].CustomerCountry;
         lblRetrievePhone.Text           = booking[0].CustomerPhone;
         lblRetrieveBookingNotes.Text    = booking[0].BookingNotes;
         pReservationInformation.Visible = true;
         gvRetrieveBooking.Visible       = true;
         //UpdatePanelRetrieveBooking.Update();
     }
     UpdatePanelRetrieveBooking.Update();
 }
Пример #3
0
 protected void btnRetrieveBooking_Click(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         lblRetrieveName.Visible         = false;
         lblRetrieveCountry.Visible      = false;
         lblRetrievePhone.Visible        = false;
         lblRetrieveBookingNotes.Visible = false;
         string email = txtRetrieveBookingEmail.Text;
         string id    = txtRetrieveBookingID.Text;
         List <BookingElement> booking = BookingElement.RetrieveBookingDetails(email, id);
         lblRetrieveName.Text            = booking[0].CustomerName;
         lblRetrieveCountry.Text         = booking[0].CustomerCountry;
         lblRetrievePhone.Text           = booking[0].CustomerPhone;
         lblRetrieveBookingNotes.Text    = booking[0].BookingNotes;
         lblRetrieveName.Visible         = true;
         lblRetrieveCountry.Visible      = true;
         lblRetrievePhone.Visible        = true;
         lblRetrieveBookingNotes.Visible = true;
         gvRetrieveBooking.DataSource    = dsRetrieveBooking.Select();
         gvRetrieveBooking.DataBind();
     }
 }
Пример #4
0
        protected void ReserveSelectedRooms_Click(object sender, EventArgs e)
        {
            //Email TxtBox Validation PT  3
            // disable unobtrusive validation
            UnobtrusiveValidationMode =
                System.Web.UI.UnobtrusiveValidationMode.None;
            // if this is not the first time the page is loading
            // (i.e., the user has already submitted form data)
            if (IsPostBack)
            {
                Page.Validate("UpdatePanelReturnAvailabilityValidation");  // validate the form

                // if the form is valid
                if (IsValid)
                {
                    // retrieve the values submitted by the user
                    string validEmail = txtCustomerEmail.Text;
                    // show the submitted values
                    GordTestLabelRESERVE.Text = validEmail;
                } // end if
            }
            //Retrieve date from the gridview and create new BookingElement List
            List <BookingElement> userSelectedBookingElements = new List <BookingElement>();

            foreach (GridViewRow row in gvAvailability.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("cbxUserSelection");
                if (cb != null && cb.Checked)
                {
                    BookingElement b = new BookingElement();
                    b.UserDate = Convert.ToDateTime(gvAvailability.Rows[row.RowIndex].Cells[0].Text);
                    b.RoomID   = Convert.ToInt32(gvAvailability.Rows[row.RowIndex].Cells[1].Text);
                    DropDownList dl = (DropDownList)row.FindControl("ddlUserGuests");
                    b.NumberOfGuests = Convert.ToInt32(dl.SelectedItem.Text);
                    userSelectedBookingElements.Add(b);
                }
            }

            //add back in room rates for selected dates
            BookingElement.AddRoomRateByDate(currentRoomData, ref userSelectedBookingElements);

            //Add any booking notes to each element
            if (!string.IsNullOrEmpty(txtCustomerBookingNotes.Text) &&
                userSelectedBookingElements.Count > 0)
            {
                BookingElement.AddBookingNotesToBookingElements(txtCustomerBookingNotes.Text,
                                                                ref userSelectedBookingElements);
            }

            //check if customer exists and if yes, capture relevant data
            customerEmail = txtCustomerEmail.Text;
            if (DBMethods.CheckExistingCustomer(customerEmail).ToString() == "false")
            {
                UpdatePanelRegisterNewCustomer.Visible = true;
            }
            if (userSelectedBookingElements.Count > 0)
            {
                bookingID = DBMethods.CreateBookingID(customerEmail, txtCustomerBookingNotes.Text);
                BookingElement.AddingBookingIDToBookingElements(bookingID, ref userSelectedBookingElements);
                DBMethods.CreateBookingElements(userSelectedBookingElements);
                BookingIDReference.InnerHtml = bookingID.ToString();
            }
        }
Пример #5
0
        protected void MakeBooking_Click(object sender, EventArgs e)
        {
            Page.Validate("CustomerDetails");
            if (Page.IsValid)
            {
                //Retrieve date from the gridview and create new BookingElement List

                foreach (GridViewRow row in gvAvailability.Rows)
                {
                    CheckBox     cb = (CheckBox)row.FindControl("cbxUserSelection");
                    DropDownList dl = (DropDownList)row.FindControl("ddlUserGuests");
                    if (cb != null && cb.Checked && Convert.ToInt32(dl.SelectedItem.Text) != 0)
                    {
                        BookingElement b = new BookingElement();
                        b.ReservationDate = Convert.ToDateTime(gvAvailability.Rows[row.RowIndex].Cells[0].Text);
                        b.RoomID          = Convert.ToInt32(gvAvailability.Rows[row.RowIndex].Cells[1].Text);

                        b.NumberOfGuests = Convert.ToInt32(dl.SelectedItem.Text);
                        userSelectedBookingElements.Add(b);
                    }
                    else
                    {
                        NothingSelected.Visible = true;
                    }
                }

                //add back in room rates for selected dates
                BookingElement.AddRoomRateByDate(currentRoomData, ref userSelectedBookingElements);

                //Add any booking notes to each element
                if (!string.IsNullOrEmpty(txtCustomerBookingNotes.Text) &&
                    userSelectedBookingElements.Count > 0)
                {
                    BookingElement.AddBookingNotesToBookingElements(txtCustomerBookingNotes.Text,
                                                                    ref userSelectedBookingElements);
                }

                customerEmail = txtEmail.Text.ToString();
                string phone   = txtCustomerPhone.Text.ToString();
                string country = ddlCountry.SelectedValue.ToString();                 //TODO Validation to say can't select default item
                string name    = txtCustomerName.Text.ToString();

                if (userSelectedBookingElements.Count > 0)                 //&& !string.IsNullOrEmpty(phone)
                //&& !string.IsNullOrEmpty(country) && !string.IsNullOrEmpty(name))
                {
                    if (existingCustomer == false)
                    {
                        DBMethods.CreateNewCustomer(customerEmail, country, name, phone);
                    }
                    bookingID = DBMethods.CreateBookingID(customerEmail, txtCustomerBookingNotes.Text);
                    BookingElement.AddingBookingIDToBookingElements(bookingID, ref userSelectedBookingElements);
                    DBMethods.CreateBookingElements(userSelectedBookingElements);

                    Session["BookingID"] = bookingID.ToString();;
                    Response.Redirect("BookingConfirm.aspx");
                }
                else
                {
                    NothingSelected.Visible = true;
                }
            }
            //else
            //{
            //	NotExistingCustomer.Visible = false;
            //	lblCustomerName.CssClass = "hidden";
            //	txtCustomerName.Text = string.Empty;
            //	txtCustomerName.CssClass = "hidden";
            //	lblCustomerPhone.CssClass = "hidden";
            //	txtCustomerPhone.Text = string.Empty;
            //	txtCustomerPhone.CssClass = "hidden";
            //	lblCustomerCountry.CssClass = "hidden";
            //	ddlCountry.SelectedIndex = 0;
            //	ddlCountry.CssClass = "hidden";
            //	MakeBooking.CssClass = "hidden";
            //	UpdatePanelRegisterNewCustomer.Update();
            //}
        }