protected void btnDelete_Click(object sender, EventArgs e)
        {
            Button               btnDelete    = (Button)sender;
            RepeaterItem         item         = (RepeaterItem)btnDelete.Parent;
            CustomerInfoRowInput customerData = item.FindControl("customerData") as CustomerInfoRowInput;

            if (customerData != null)
            {
                Customer customer = customerData.NewCustomer(Module);
                Module.Delete(customer);
                var history = new BookingHistory();
                history.Booking        = Booking;
                history.Date           = DateTime.Now;
                history.Agency         = Booking.Agency;
                history.StartDate      = Booking.StartDate;
                history.Status         = Booking.Status;
                history.Trip           = Booking.Trip;
                history.User           = UserIdentity;
                history.SpecialRequest = Booking.SpecialRequest;
                history.NumberOfPax    = (Booking.Adult + Booking.Child + Booking.Baby);
                history.CustomerInfo   = Booking.Note;
                Module.SaveOrUpdate(history);
            }
            PageRedirect(Request.RawUrl);
        }
        protected void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.Params[txtPickup.UniqueID]))
            {
                ShowWarning("Pick up address is required.");
            }

            //ScreenCaptureSave();
            BookingSetData();
            BookingViewBLL.BookingSaveOrUpdate(Booking);
            ShowSuccess("Booking updated. Please fix errors if exists and submit again");

            bool   needEmail = !Booking.Special && chkSpecial.Checked;
            string email     = string.Empty;

            if (needEmail)
            {
                email = "&confirm=1";
            }
            foreach (RepeaterItem extraService in rptExtraServices.Items)
            {
                var chkService = (HtmlInputCheckBox)extraService.FindControl("chkService");
                if (chkService.Checked)
                {
                    SaveExtraService();
                }
                else
                {
                    DeleteExtraService();
                }
            }
            foreach (RepeaterItem item in rptCustomers.Items)
            {
                CustomerInfoRowInput customerInfo1 = item.FindControl("customerData") as CustomerInfoRowInput;
                if (customerInfo1 != null)
                {
                    Customer customer1 = customerInfo1.NewCustomer(Module);
                    customer1.Booking = this.Booking;
                    Module.SaveOrUpdate(customer1);

                    Repeater rptService1 = item.FindControl("rptServices1") as Repeater;
                    if (rptService1 != null)
                    {
                        if (DetailService)
                        {
                            CustomerServiceRepeaterHandler.Save(rptService1, Module, customer1);
                        }
                    }
                }
            }
            Booking.EndDate     = Booking.StartDate.AddDays(Booking.Trip.NumberOfDay - 1);
            Session["Redirect"] = true;
            PageRedirect(string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}{3}", Node.Id, Section.Id, Booking.Id, email));
        }
Exemple #3
0
        public void BookingRoomProcess()
        {
            bool canChange = false;

            foreach (RepeaterItem item in rptRoomList.Items)
            {
                var txtRoomNumber       = (TextBox)item.FindControl("txtRoomNumber");
                var hiddenBookingRoomId = (HiddenField)item.FindControl("hiddenBookingRoomId");
                var checkBoxAddChild    = (HtmlInputCheckBox)item.FindControl("checkBoxAddChild");
                var checkBoxAddBaby     = (HtmlInputCheckBox)item.FindControl("checkBoxAddBaby");
                var checkBoxSingle      = (HtmlInputCheckBox)item.FindControl("checkBoxSingle");
                var customerInfo1       = (CustomerInfoRowInput)item.FindControl("customer1");
                var customerInfo2       = (CustomerInfoRowInput)item.FindControl("customer2");

                BookingRoom bookingRoom = Module.BookingRoomGetById(Convert.ToInt32(hiddenBookingRoomId.Value));
                bookingRoom.HasBaby    = checkBoxAddBaby.Checked;
                bookingRoom.HasChild   = checkBoxAddChild.Checked;
                bookingRoom.IsSingle   = checkBoxSingle.Checked;
                bookingRoom.RoomNumber = txtRoomNumber.Text;

                DropDownList ddlRoomTypeChanger         = (DropDownList)item.FindControl("ddlRoomTypes");
                var          stringBookingRoomTypeClass = string.Format("{0}|{1}", bookingRoom.RoomClass.Id, bookingRoom.RoomType.Id);
                if (ddlRoomTypeChanger.Visible && ddlRoomTypeChanger.SelectedValue != stringBookingRoomTypeClass)
                {
                    string[]  ids      = ddlRoomTypeChanger.SelectedValue.Split('|');
                    RoomTypex newType  = Module.RoomTypexGetById(Convert.ToInt32(ids[1]));
                    RoomClass newClass = Module.RoomClassGetById(Convert.ToInt32(ids[0]));

                    int available = Module.RoomCount(newClass, newType, Booking.Cruise, Booking.StartDate, Booking.Trip.NumberOfDay, Booking.Trip.HalfDay);
                    if (available > 0)
                    {
                        canChange = true;
                    }
                    else
                    {
                        canChange = false;
                        ShowErrors("Cant not change room" + bookingRoom.RoomClass.Name + bookingRoom.RoomType.Name + " to " + newClass.Name + newType.Name + "because not enough room " + newClass.Name + newType.Name + " available. Please check again");
                    }

                    if (canChange)
                    {
                        bookingRoom.RoomType  = newType;
                        bookingRoom.RoomClass = newClass;
                        bookingRoom.Room      = null;
                    }
                }
                Module.SaveOrUpdate(bookingRoom);
                bookingRoom.Customers.Clear();

                Customer customer1 = customerInfo1.NewCustomer(Module);
                customer1.Booking = Booking;
                customer1.BookingRooms.Clear();
                customer1.BookingRooms.Add(bookingRoom);
                customer1.Type = CustomerType.Adult;
                Module.SaveOrUpdate(customer1);

                if (!checkBoxSingle.Checked)
                {
                    Customer customer2 = customerInfo2.NewCustomer(Module);
                    customer2.Booking = Booking;
                    customer2.BookingRooms.Clear();
                    customer2.BookingRooms.Add(bookingRoom);
                    customer2.Type = CustomerType.Adult;
                    Module.SaveOrUpdate(customer2);
                }

                CustomerInfoRowInput customerChild = (CustomerInfoRowInput)item.FindControl("customerChild");
                Customer             child         = customerChild.NewCustomer(Module);
                if (checkBoxAddChild.Checked)
                {
                    child.Booking = Booking;
                    child.BookingRooms.Clear();
                    child.BookingRooms.Add(bookingRoom);
                    child.Type = CustomerType.Children;
                    Module.SaveOrUpdate(child);
                }

                CustomerInfoRowInput customerBaby = (CustomerInfoRowInput)item.FindControl("customerBaby");
                Customer             baby         = customerBaby.NewCustomer(Module);
                if (checkBoxAddBaby.Checked)
                {
                    baby.Booking = Booking;
                    baby.BookingRooms.Clear();
                    baby.BookingRooms.Add(bookingRoom);
                    baby.Type = CustomerType.Baby;
                    Module.SaveOrUpdate(baby);
                }
            }
        }