Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 protected void rptCustomers_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.DataItem is Customer)
     {
         Customer             customer     = (Customer)e.Item.DataItem;
         CustomerInfoRowInput customerData = e.Item.FindControl("customerData") as CustomerInfoRowInput;
         if (customerData != null)
         {
             customerData.GetCustomer(customer, Module);
         }
     }
 }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Dùng cho sự kiện data bound của một danh sách booking room
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="module"></param>
        /// <param name="customPrice"></param>
        /// <param name="policies"></param>
        /// <param name="page"></param>
        /// <param name="roomTypes"></param>
        public static void rptRoomList_itemDataBound(object sender, RepeaterItemEventArgs e, SailsModule module, bool customPrice, IList policies, SailsAdminBasePage page, ListItemCollection roomTypes)
        {
            if (e.Item.ItemType != ListItemType.Header)
            {
                BookingRoom item = e.Item.DataItem as BookingRoom;
                if (item != null)
                {
                    #region -- Thông tin thường --

                    Label lblRoomName = (Label)e.Item.FindControl("lblRoomName");
                    if (item.Room != null)
                    {
                        Label label_RoomId = (Label)e.Item.FindControl("label_RoomId");
                        label_RoomId.Text = item.Room.Id.ToString();
                        if (item.Room != null)
                        {
                            lblRoomName.Text = string.Format("{2}: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{0} {1}",
                                                             item.RoomClass.Name, item.RoomType.Name,
                                                             item.Room.Name);
                        }
                        else
                        {
                            lblRoomName.Text = string.Format("{0} {1}",
                                                             item.RoomClass.Name, item.RoomType.Name);
                        }
                    }
                    else
                    {
                        lblRoomName.Text = string.Format("Room {2}: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{0} {1}",
                                                         item.RoomClass.Name, item.RoomType.Name,
                                                         e.Item.ItemIndex + 1);
                    }

                    HiddenField hiddenRoomClassId = (HiddenField)e.Item.FindControl("hiddenRoomClassId");
                    HiddenField hiddenRoomTypeId  = (HiddenField)e.Item.FindControl("hiddenRoomTypeId");

                    hiddenRoomClassId.Value = item.RoomClass.Id.ToString();
                    hiddenRoomTypeId.Value  = item.RoomType.Id.ToString();

                    if (item.Booked == 1 && item.RoomType.Id == SailsModule.TWIN)
                    {
                        e.Item.FindControl("trCustomer2").Visible = false;
                        e.Item.FindControl("trExtra").Visible     = false;
                    }

                    HtmlInputCheckBox checkBoxAddChild = (HtmlInputCheckBox)e.Item.FindControl("checkBoxAddChild");
                    HtmlControl       trChild          = (HtmlControl)e.Item.FindControl("trChild");

                    string scriptChild = string.Format(@"toggleVisible('{0}');",
                                                       trChild.ClientID);
                    checkBoxAddChild.Attributes.Add("onclick", scriptChild);

                    HtmlInputCheckBox checkBoxAddBaby = (HtmlInputCheckBox)e.Item.FindControl("checkBoxAddBaby");
                    HtmlControl       trBaby          = (HtmlControl)e.Item.FindControl("trBaby");
                    string            scriptBaby      = string.Format(@"toggleVisible('{0}');", trBaby.ClientID);
                    checkBoxAddBaby.Attributes.Add("onclick", scriptBaby);

                    HtmlInputCheckBox checkBoxSingle = (HtmlInputCheckBox)e.Item.FindControl("checkBoxSingle");
                    HtmlControl       trCustomer2    = (HtmlControl)e.Item.FindControl("trCustomer2");
                    string            scriptCustomer = string.Format(@"toggleVisible('{0}');",
                                                                     trCustomer2.ClientID);
                    checkBoxSingle.Attributes.Add("onclick", scriptCustomer);

                    #endregion

                    #region -- (back-end) --

                    bool isSecond = false;
                    // Load customer info đã có

                    #region -- customer info --

                    foreach (Customer customer in item.Customers)
                    {
                        if (customer != null && customer.Type == CustomerType.Adult)
                        {
                            if (!isSecond)
                            {
                                CustomerInfoRowInput customer1   = e.Item.FindControl("customer1") as CustomerInfoRowInput;
                                Repeater             rptService1 = e.Item.FindControl("rptServices1") as Repeater;
                                if (customer1 != null && rptService1 != null)
                                {
                                    customer1.GetCustomer(customer, module);
                                    if (page.DetailService)
                                    {
                                        CustomerServiceRepeaterHandler handler =
                                            new CustomerServiceRepeaterHandler(customer, module);
                                        rptService1.DataSource     = module.CustomerServices;
                                        rptService1.ItemDataBound += handler.ItemDataBound;
                                        rptService1.DataBind();
                                    }
                                    else
                                    {
                                        rptService1.Visible = false;
                                    }
                                    isSecond = true;
                                }
                            }
                            else
                            {
                                CustomerInfoRowInput customer2   = e.Item.FindControl("customer2") as CustomerInfoRowInput;
                                Repeater             rptService2 = e.Item.FindControl("rptServices2") as Repeater;
                                if (customer2 != null && rptService2 != null)
                                {
                                    customer2.GetCustomer(customer, module);
                                    if (page.DetailService)
                                    {
                                        CustomerServiceRepeaterHandler handler =
                                            new CustomerServiceRepeaterHandler(customer, module);
                                        rptService2.DataSource     = module.CustomerServices;
                                        rptService2.ItemDataBound += handler.ItemDataBound;
                                        rptService2.DataBind();
                                    }
                                    else
                                    {
                                        rptService2.Visible = false;
                                    }
                                }
                            }
                        }


                        if (customer.Type == CustomerType.Children)
                        {
                            CustomerInfoRowInput customerChild =
                                e.Item.FindControl("customerChild") as CustomerInfoRowInput;
                            Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater;
                            if (customerChild != null && rptServicesChild != null)
                            {
                                customerChild.GetCustomer(customer, module);
                                if (page.DetailService)
                                {
                                    CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(
                                        customer, module);
                                    rptServicesChild.DataSource     = module.CustomerServices;
                                    rptServicesChild.ItemDataBound += handler.ItemDataBound;
                                    rptServicesChild.DataBind();
                                }
                                else
                                {
                                    rptServicesChild.Visible = false;
                                }
                            }
                        }

                        if (customer.Type == CustomerType.Baby)
                        {
                            CustomerInfoRowInput customerBaby    = e.Item.FindControl("customerBaby") as CustomerInfoRowInput;
                            Repeater             rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater;
                            if (customerBaby != null && rptServicesBaby != null)
                            {
                                customerBaby.GetCustomer(customer, module);
                                if (page.DetailService)
                                {
                                    CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(
                                        customer, module);
                                    rptServicesBaby.DataSource     = module.CustomerServices;
                                    rptServicesBaby.ItemDataBound += handler.ItemDataBound;
                                    rptServicesBaby.DataBind();
                                }
                                else
                                {
                                    rptServicesBaby.Visible = false;
                                }
                            }
                        }
                    }

                    #endregion

                    #region -- Check box và visible --

                    checkBoxSingle.Checked   = false;
                    checkBoxAddChild.Checked = false;
                    checkBoxAddBaby.Checked  = false;

                    if (item.Adult == 1)
                    {
                        trCustomer2.Attributes.CssStyle["display"] = "none";
                        checkBoxSingle.Checked = true;
                    }

                    trChild.Attributes.CssStyle["display"] = "none";
                    if (item.HasChild)
                    {
                        trChild.Attributes.CssStyle["display"] = "";
                        checkBoxAddChild.Checked = true;
                    }
                    else
                    {
                        Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater;
                        if (rptServicesChild != null)
                        {
                            rptServicesChild.DataSource = module.CustomerServices;
                            rptServicesChild.DataBind();
                        }
                    }

                    trBaby.Attributes.CssStyle["display"] = "none";
                    if (item.HasBaby)
                    {
                        trBaby.Attributes.CssStyle["display"] = "";
                        checkBoxAddBaby.Checked = true;
                    }
                    else
                    {
                        Repeater rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater;
                        if (rptServicesBaby != null)
                        {
                            rptServicesBaby.DataSource = module.CustomerServices;
                            rptServicesBaby.DataBind();
                        }
                    }

                    #endregion

                    // Load room available

                    #region -- available --

                    //DropDownList ddlRooms = e.Item.FindControl("ddlRooms") as DropDownList;
                    //if (ddlRooms != null)
                    //{
                    //    // Danh sách phòng được chọn bao gồm: toàn bộ các phòng chưa được chọn và phòng trong book hiện tại
                    //    IList datasouce = module.RoomGetAvailable(item.Book.Cruise, item, (item.Book.EndDate - item.Book.StartDate).Days,
                    //                                              item.Book);
                    //    Room room = new Room("", false, null, null);
                    //    datasouce.Insert(0, room);
                    //    ddlRooms.DataSource = datasouce;
                    //    ddlRooms.DataTextField = "Name";
                    //    ddlRooms.DataValueField = "Id";
                    //    ddlRooms.DataBind();

                    //    if (item.Room != null)
                    //    {
                    //        ListItem listItem = ddlRooms.Items.FindByValue(item.Room.Id.ToString());
                    //        if (listItem != null)
                    //        {
                    //            listItem.Selected = true;
                    //        }
                    //    }
                    //}

                    var txtRoomNumber = e.Item.FindControl("txtRoomNumber") as TextBox;
                    txtRoomNumber.Text = item.RoomNumber;

                    #endregion

                    DropDownList ddlRoomTypes = e.Item.FindControl("ddlRoomTypes") as DropDownList;
                    if (ddlRoomTypes != null)
                    {
                        if (item.VirtualAdult == 2)
                        {
                            ddlRoomTypes.DataSource     = roomTypes; //module.RoomTypexGetAll();
                            ddlRoomTypes.DataValueField = "Value";
                            ddlRoomTypes.DataTextField  = "Text";
                            ddlRoomTypes.DataBind();

                            ListItem listitem =
                                ddlRoomTypes.Items.FindByValue(string.Format("{0}|{1}", item.RoomClass.Id,
                                                                             item.RoomType.Id));

                            if (listitem != null)
                            {
                                listitem.Selected = true;
                            }
                            else
                            {
                                ddlRoomTypes.Items.Add(new ListItem(item.RoomClass.Name + " " + item.RoomType.Name,
                                                                    string.Format("{0}|{1}", item.RoomClass.Id,
                                                                                  item.RoomType.Id)));
                                ddlRoomTypes.SelectedValue = string.Format("{0}|{1}", item.RoomClass.Id,
                                                                           item.RoomType.Id);
                            }
                        }
                        else
                        {
                            ddlRoomTypes.Visible = false;
                            e.Item.FindControl("labelRoomTypes").Visible = false;
                        }
                    }

                    #endregion
                }
            }
        }