Exemple #1
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();
            }
        }
Exemple #2
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();
            //}
        }