コード例 #1
0
        public void RevenueExportBySalesToSheet(ExcelWorksheet sheet, IList <Booking> salesBookings)
        {
            double _totalUSD = 0;
            double _totalVnd = 0;
            int    _adult    = 0;
            int    _child    = 0;

            foreach (Booking booking in salesBookings)
            {
                if (booking.IsTotalUsd)
                {
                    _totalUSD += booking.Value;
                }
                else
                {
                    _totalVnd += booking.Value;
                }
                _adult += booking.Adult;
                _child += booking.Child;
            }

            sheet.Cells["G9"].Value  = _adult;
            sheet.Cells["H9"].Value  = _child;
            sheet.Cells["J9"].Value  = _totalUSD;
            sheet.Cells["K9"].Value  = _totalVnd;
            sheet.Cells["G16"].Value = UserIdentity.FullName;

            int firstRow = 7;

            sheet.Rows[firstRow].InsertCopy(salesBookings.Count - 1, sheet.Rows[firstRow]);

            int activeRow = firstRow;

            foreach (Booking booking in salesBookings)
            {
                IList _policies;
                if (booking.Agency != null && booking.Agency.Role != null)
                {
                    _policies = Module.AgencyPolicyGetByRole(booking.Agency.Role);
                }
                else
                {
                    _policies = Module.AgencyPolicyGetByRole(Module.RoleGetById(4));
                }

                if (booking.BookingSale.Sale != null)
                {
                    sheet.Cells[activeRow, 0].Value = booking.BookingSale.Sale.FullName;
                }

                sheet.Cells[activeRow, 1].Value = string.Format("OS{0:00000}", booking.Id);
                if (!string.IsNullOrEmpty(booking.AgencyCode))
                {
                    sheet.Cells[activeRow, 1].Value = booking.AgencyCode;
                }

                sheet.Cells[activeRow, 2].Value = "OrientalSails";
                if (booking.Agency != null)
                {
                    sheet.Cells[activeRow, 2].Value = booking.Agency.Name;
                }

                sheet.Cells[activeRow, 3].Value = booking.Trip.TripCode + booking.TripOption;
                if (booking.Trip.NumberOfOptions <= 1)
                {
                    sheet.Cells[activeRow, 3].Value = booking.Trip.TripCode;
                }


                sheet.Cells[activeRow, 4].Value = booking.StartDate;
                sheet.Cells[activeRow, 5].Value = booking.EndDate;

                sheet.Cells[activeRow, 6].Value = booking.Adult;
                sheet.Cells[activeRow, 7].Value = booking.Child;

                double unitprice;
                try
                {
                    Room room = Module.RoomGetById(SailsModule.DOUBLE);
                    unitprice = BookingRoom.Calculate(room.RoomClass, room.RoomType, 1, 0, false,
                                                      booking.Trip, booking.Cruise, booking.TripOption,
                                                      booking.StartDate, Module, _policies, ChildPrice,
                                                      AgencySupplement, booking.Agency);
                }
                catch
                {
                    unitprice = 0;
                }

                foreach (ExtraOption service in booking.ExtraServices)
                {
                    if (service.Deleted)
                    {
                        continue;
                    }

                    if (service.IsIncluded && !booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice - service.Price;
                    }

                    if (!service.IsIncluded && booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice + service.Price;
                    }
                }

                sheet.Cells[activeRow, 8].Value = unitprice;

                if (booking.CurrencyRate == 0)
                {
                    if (booking.IsTotalUsd)
                    {
                        booking.CurrencyRate = Module.ExchangeGetByDate((DateTime.Now)).Rate;
                    }
                }

                if (booking.IsTotalUsd == false)
                {
                    booking.CurrencyRate = 1;
                }

                if (booking.IsTotalUsd)
                {
                    sheet.Cells[activeRow, 9].Value = booking.Value;
                }
                else
                {
                    sheet.Cells[activeRow, 10].Value = booking.Value;
                }

                activeRow++;
            }
        }
コード例 #2
0
        public void RevenueExportByCruiseToSheet(ExcelWorksheet sheet, IList <Booking> cruiseBookings)
        {
            double _totalUSD = 0;
            double _totalVND = 0;
            double _totalAll = 0;

            foreach (Booking booking in cruiseBookings)
            {
                if (booking.CurrencyRate == 0)
                {
                    if (booking.IsTotalUsd)
                    {
                        booking.CurrencyRate = Module.ExchangeGetByDate((DateTime.Now)).Rate;
                    }
                }

                if (booking.IsTotalUsd == false)
                {
                    booking.CurrencyRate = 1;
                }

                if (booking.IsTotalUsd)
                {
                    _totalUSD += booking.Value;
                }
                else
                {
                    _totalVND += booking.Value;
                }

                _totalAll += (booking.Value * booking.CurrencyRate);
            }

            sheet.Cells["K9"].Value  = _totalUSD;
            sheet.Cells["L9"].Value  = _totalVND;
            sheet.Cells["N9"].Value  = _totalAll;
            sheet.Cells["M16"].Value = CurrentUser.FullName;

            int firstrow = 7;

            sheet.Rows[firstrow].InsertCopy(cruiseBookings.Count - 1, sheet.Rows[firstrow]);

            int activeRow = 7;

            foreach (Booking booking in cruiseBookings)
            {
                IList _policies;
                if (booking.Agency != null && booking.Agency.Role != null)
                {
                    _policies = Module.AgencyPolicyGetByRole(booking.Agency.Role);
                }
                else
                {
                    _policies = Module.AgencyPolicyGetByRole(Module.RoleGetById(4));
                }


                if (booking.BookingSale.Sale != null)
                {
                    sheet.Cells[activeRow, 0].Value = booking.BookingSale.Sale.FullName;
                }
                sheet.Cells[activeRow, 1].Value = string.Format("OS{0:00000}", booking.Id);
                if (!string.IsNullOrEmpty(booking.AgencyCode))
                {
                    sheet.Cells[activeRow, 1].Value = booking.AgencyCode;
                }
                sheet.Cells[activeRow, 2].Value = SailsModule.NOAGENCY;
                if (booking.Agency != null)
                {
                    sheet.Cells[activeRow, 2].Value = booking.Agency.Name;
                }

                sheet.Cells[activeRow, 3].Value = booking.StartDate;
                sheet.Cells[activeRow, 4].Value = booking.EndDate;
                sheet.Cells[activeRow, 5].Value = booking.Trip.TripCode + booking.TripOption;
                if (booking.Trip.NumberOfOptions <= 1)
                {
                    sheet.Cells[activeRow, 5].Value = booking.Trip.TripCode;
                }


                if (booking.ExtraServices.Select(x => x.Id).Contains(Module.ExtraOptionGetById(SailsModule.TRANSFER).Id))
                {
                    sheet.Cells[activeRow, 6].Value = "Yes";
                }
                else
                {
                    sheet.Cells[activeRow, 6].Value = "No";
                }

                sheet.Cells[activeRow, 7].Value = booking.Adult;
                sheet.Cells[activeRow, 8].Value = booking.Child;

                double unitprice;
                try
                {
                    Room room = Module.RoomGetById(SailsModule.DOUBLE);
                    unitprice = BookingRoom.Calculate(room.RoomClass, room.RoomType, 1, 0, false,
                                                      booking.Trip, booking.Cruise, booking.TripOption,
                                                      booking.StartDate, Module, _policies, ChildPrice,
                                                      AgencySupplement, booking.Agency);
                }
                catch (PriceException)
                {
                    unitprice = 0;
                }
                foreach (ExtraOption service in booking.ExtraServices)
                {
                    if (service.Deleted)
                    {
                        continue;
                    }

                    if (service.IsIncluded && !booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice - service.Price;
                    }

                    if (!service.IsIncluded && booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice + service.Price;
                    }
                }

                sheet.Cells[activeRow, 9].Value = unitprice;

                if (booking.CurrencyRate == 0)
                {
                    if (booking.IsTotalUsd)
                    {
                        booking.CurrencyRate = Module.ExchangeGetByDate((DateTime.Now)).Rate;
                    }
                }

                if (booking.IsTotalUsd == false)
                {
                    booking.CurrencyRate = 1;
                }

                if (booking.IsTotalUsd)
                {
                    sheet.Cells[activeRow, 10].Value = booking.Value;
                }
                else
                {
                    sheet.Cells[activeRow, 11].Value = booking.Value;
                }
                sheet.Cells[activeRow, 12].Value = booking.CurrencyRate;
                sheet.Cells[activeRow, 13].Value = booking.Value * booking.CurrencyRate;

                if (booking.MoneyLeft != 0)
                {
                    if (booking.Paid == 0 && booking.PaidBase == 0)
                    {
                        sheet.Cells[activeRow, 14].Value = "Unpaid";
                    }
                    else
                    {
                        sheet.Cells[activeRow, 14].Value = "Partly paid";
                    }
                }
                else
                {
                    sheet.Cells[activeRow, 14].Value = "Paid";
                    if (booking.PaidDate.HasValue)
                    {
                        sheet.Cells[activeRow, 14].Value = booking.PaidDate.Value;
                    }
                }
                activeRow++;
            }
        }
コード例 #3
0
        protected void rptTypes_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is RoomTypex)
            {
                RoomTypex type      = (RoomTypex)e.Item.DataItem;
                Label     labelName = e.Item.FindControl("labelName") as Label;
                if (labelName != null)
                {
                    labelName.Text = string.Format("{0} {1}", _roomClass.Name, type.Name);
                }

                #region -- thông tin về khách và phòng trống --

                DropDownList ddlAdults = (DropDownList)e.Item.FindControl("ddlAdults");
                DropDownList ddlChild  = (DropDownList)e.Item.FindControl("ddlChild");
                DropDownList ddlBaby   = (DropDownList)e.Item.FindControl("ddlBaby");
                if (Date != null)
                {
                    ddlAdults.Items.Clear();
                    ddlChild.Items.Clear();
                    ddlBaby.Items.Clear();

                    int roomCount;

                    Locked locked = Module.LockedCheckByDate(ActiveCruise, Date.Value,
                                                             Date.Value.AddDays(Trip.NumberOfDay - 1));
                    if (locked != null)
                    {
                        if (!string.IsNullOrEmpty(locked.Description))
                        {
                            ShowErrors(
                                string.Format(
                                    "Hành trình này đã bị khóa với lý do: {0}, vẫn có thể add booking như buộc phải chuyển sang tàu khác",
                                    locked.Description));
                        }
                        else
                        {
                            ShowErrors(
                                string.Format(
                                    "Hành trình này đã bị khóa, vẫn có thể add booking như buộc phải chuyển sang tàu khác"));
                        }
                        // Khi ấy thì lấy về số phòng, trong đó bỏ qua lock
                        roomCount = Module.RoomCount(_roomClass, type, ActiveCruise, Date.Value, Trip.NumberOfDay, true,
                                                     Trip.HalfDay);
                    }
                    else
                    {
                        roomCount = Module.RoomCount(_roomClass, type, ActiveCruise, Date.Value, Trip.NumberOfDay,
                                                     Trip.HalfDay);
                    }

                    if (roomCount < 0)
                    {
                        e.Item.Visible = false;
                        return;
                    }
                    int maxAdults;

                    // Nếu là phòng ở ghép thì số người = giá trị lấy về, số phòng = giá trị lấy về chia cho sức chứa
                    if (type.IsShared)
                    {
                        maxAdults = roomCount;
                        roomCount = roomCount / type.Capacity;
                    }
                    else
                    {
                        // Nếu không số người = giá gị lấy về nhân với sức chứa
                        maxAdults = roomCount * type.Capacity;
                    }

                    // Nếu là phòng ở ghép thì cho chọn theo số người
                    if (type.IsShared)
                    {
                        // Từ 0 đến số người max
                        for (int i = 0; i <= maxAdults; i++)
                        {
                            ddlAdults.Items.Add(new ListItem(string.Format(Resources.formatPersonItem, i), i.ToString()));
                        }
                    }
                    else
                    {
                        // Nếu không phải phòng ở ghép thì lấy theo số phòng
                        for (int i = 0; i <= roomCount; i++)
                        {
                            ddlAdults.Items.Add(new ListItem(string.Format(Resources.formatRoomItem, i), i.ToString()));
                        }
                    }

                    for (int i = 0; i <= roomCount; i++)
                    {
                        ddlBaby.Items.Add(new ListItem(string.Format(Resources.formatBabyItem, i), i.ToString()));
                        ddlChild.Items.Add(new ListItem(string.Format(Resources.formatChildItem, i), i.ToString()));
                    }
                }

                #endregion

                #region -- Giá thủ công --

                // Nếu hệ thống được cấu hình để nhập giá thủ công cho từng loại phòng ngay khi add booking thì hiển thị khu vực này
                PlaceHolder plhCustomPrice = e.Item.FindControl("plhCustomPrice") as PlaceHolder;
                if (plhCustomPrice != null)
                {
                    if (CustomPriceAddBooking)
                    {
                        plhCustomPrice.Visible = true;
                        TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox;
                        if (txtPrice != null)
                        {
                            double price;
                            try
                            {
                                price = BookingRoom.Calculate(_roomClass, type, type.Capacity, 0, false, _trip,
                                                              ActiveCruise,
                                                              TripOption.Option1, Date.Value, Module, _policies,
                                                              ChildPrice, AgencySupplement, null);
                            }
                            catch (PriceException ex)
                            {
                                ShowErrors(ex.Message);
                                price = 0;
                            }
                            txtPrice.Text = price.ToString("0.##");
                        }
                    }
                    else
                    {
                        plhCustomPrice.Visible = false;
                    }
                }

                #endregion
            }
        }
コード例 #4
0
        public void ReceivableExportByAgencyToSheet(ExcelWorksheet sheet, IList <Booking> agencyBookings)
        {
            int firstrow = 12;

            sheet.Rows[firstrow].InsertCopy(agencyBookings.Count - 1, sheet.Rows[firstrow]);

            int activeRow = 12;
            var index     = 1;

            foreach (Booking booking in agencyBookings)
            {
                IList _policies;
                if (booking.Agency != null && booking.Agency.Role != null)
                {
                    _policies = Module.AgencyPolicyGetByRole(booking.Agency.Role);
                }
                else
                {
                    _policies = Module.AgencyPolicyGetByRole(Module.RoleGetById(4));
                }

                sheet.Cells[activeRow, 0].Value = index;
                index++;

                sheet.Cells[activeRow, 1].Value = string.Format("OS{0:00000}", booking.Id);
                if (!string.IsNullOrEmpty(booking.AgencyCode))
                {
                    sheet.Cells[activeRow, 1].Value = booking.AgencyCode;
                }

                if (booking.Booker != null)
                {
                    sheet.Cells[activeRow, 2].Value = booking.Booker.Name;
                }

                sheet.Cells[activeRow, 3].Value = booking.StartDate;
                sheet.Cells[activeRow, 4].Value = booking.EndDate;

                sheet.Cells[activeRow, 5].Value = booking.Trip.TripCode + booking.TripOption;
                if (booking.Trip.NumberOfOptions <= 1)
                {
                    sheet.Cells[activeRow, 5].Value = booking.Trip.TripCode;
                }

                if (booking.ExtraServices.Select(x => x.Id).Contains(Module.ExtraOptionGetById(SailsModule.TRANSFER).Id))
                {
                    sheet.Cells[activeRow, 6].Value = "Yes";
                }
                else
                {
                    sheet.Cells[activeRow, 6].Value = "No";
                }


                string roomname = booking.RoomName.Replace("<br/>", "\n");
                if (roomname.Length > 0)
                {
                    roomname = roomname.Remove(roomname.Length - 1);
                }

                sheet.Cells[activeRow, 7].Value = roomname;
                sheet.Cells[activeRow, 8].Value = booking.Adult;
                sheet.Cells[activeRow, 9].Value = booking.Child;

                double unitprice;
                try
                {
                    Room room = Module.RoomGetById(SailsModule.DOUBLE);
                    unitprice = BookingRoom.Calculate(room.RoomClass, room.RoomType, 1, 0, false,
                                                      booking.Trip, booking.Cruise, booking.TripOption,
                                                      booking.StartDate, Module, _policies, ChildPrice,
                                                      AgencySupplement, booking.Agency);
                }
                catch (PriceException)
                {
                    unitprice = 0;
                }
                foreach (ExtraOption service in booking.ExtraServices)
                {
                    if (service.Deleted)
                    {
                        continue;
                    }

                    if (service.IsIncluded && !booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice - service.Price;
                    }

                    if (!service.IsIncluded && booking.ExtraServices.Select(x => x.Id).Contains(service.Id))
                    {
                        unitprice = unitprice + service.Price;
                    }
                }

                sheet.Cells[activeRow, 10].Value = unitprice;

                if (booking.CurrencyRate == 0)
                {
                    if (booking.IsTotalUsd)
                    {
                        booking.CurrencyRate = Module.ExchangeGetByDate((DateTime.Now)).Rate;
                    }
                }

                if (booking.IsTotalUsd == false)
                {
                    booking.CurrencyRate = 1;
                }

                if (booking.IsTotalUsd)
                {
                    sheet.Cells[activeRow, 11].Value = Math.Round(booking.MoneyLeft / booking.CurrencyRate);
                }
                else
                {
                    sheet.Cells[activeRow, 12].Value = Math.Round(booking.MoneyLeft / booking.CurrencyRate);
                }
                sheet.Cells[activeRow, 13].Value = booking.CurrencyRate;
                sheet.Cells[activeRow, 14].Value = booking.MoneyLeft;

                activeRow++;
            }
        }
コード例 #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;
                    }

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

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

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

                    CheckBox    checkBoxSingle      = (CheckBox)e.Item.FindControl("checkBoxSingle");
                    HtmlControl trCustomer2         = (HtmlControl)e.Item.FindControl("trCustomer2");
                    HtmlControl trCustomer2Services = (HtmlControl)e.Item.FindControl("trCustomer2Services");
                    string      scriptCustomer      = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');",
                                                                    trCustomer2.ClientID, trCustomer2Services.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.Type == CustomerType.Adult)
                        {
                            if (!isSecond)
                            {
                                CustomerInfoInput customer1   = e.Item.FindControl("customer1") as CustomerInfoInput;
                                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
                            {
                                CustomerInfoInput customer2   = e.Item.FindControl("customer2") as CustomerInfoInput;
                                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)
                        {
                            CustomerInfoInput customerChild =
                                e.Item.FindControl("customerChild") as CustomerInfoInput;
                            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)
                        {
                            CustomerInfoInput customerBaby    = e.Item.FindControl("customerBaby") as CustomerInfoInput;
                            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 --

                    if (item.VirtualAdult == 1)
                    {
                        e.Item.FindControl("trCustomer2").Visible  = false;
                        e.Item.FindControl("rptServices2").Visible = false;
                    }

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

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

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

                    #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  = Room.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;
                            }
                        }
                    }

                    #endregion

                    #region -- room price --

                    if (customPrice)
                    {
                        TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox;
                        if (txtPrice != null)
                        {
                            if (item.Total <= 0)
                            {
                                if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE)))
                                {
                                    txtPrice.Visible = false;
                                }
                                else
                                {
                                    txtPrice.Visible = true;
                                }
                                item.Total = item.Calculate(module, policies, page.ChildPrice, page.AgencySupplement, null);
                            }
                            txtPrice.Text = item.Total.ToString("0.#");
                        }
                    }
                    else
                    {
                        PlaceHolder plhRoomPrice = e.Item.FindControl("plhRoomPrice") as PlaceHolder;
                        if (plhRoomPrice != null)
                        {
                            plhRoomPrice.Visible = false;
                        }
                    }

                    #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
                }
            }
        }