protected CostingTable GetCurrentTable(DateTime date, SailsTrip trip, TripOption option)
        {
            #region -- costing table --

            if (_tableCache == null)
            {
                // Lấy về mảng costing table
                int       trips   = Module.TripMaxId() + 1;
                const int options = 3;
                _tableCache = new CostingTable[trips, options];
            }

            // Nếu bảng giá tại vị trí này là null hoặc hết hạn
            if (_tableCache[trip.Id, (int)option] == null || _tableCache[trip.Id, (int)option].ValidTo < date)
            {
                _tableCache[trip.Id, (int)option] = Module.CostingTableGetValid(date, trip, option);
            }

            _table = _tableCache[trip.Id, (int)option];

            #endregion

            if (_table == null)
            {
                throw new Exception(string.Format("No costing table for {0:dd/MM/yyyy}, {1} {2}", date, trip.Name,
                                                  option));
            }

            return(_table);
        }
Пример #2
0
        // Retrieves all the inner detail flight info for each of the trips and legs (connections)
        // for each flight related to the flight request submitted by the user
        protected static string GetDetails(Dictionary <string, Airport> airports, Google.Apis.QPXExpress.v1.Data.Data data,
                                           TripOption to, string inb, out int leg)
        {
            leg = 1;
            string res = "Outbound --> " + StrConsts._NewLine + StrConsts._NewLine;

            for (int i = 0; i <= to.Slice.Count - 1; i++)
            {
                res += GetSegmentLegs(ref leg, airports, data, to.Slice[i].Segment);

                if (inb.ToLower() == GatherQuestions.cStrGatherProcessOneWay.ToLower())
                {
                    break;
                }
                else
                if (i < to.Slice.Count - 1)
                {
                    res += StrConsts._NewLine + StrConsts._NewLine +
                           StrConsts._NewLine + StrConsts._NewLine +
                           "Inbound (Return) --> " + StrConsts._NewLine + StrConsts._NewLine;
                }
            }

            return(res);
        }
 public SailsPriceConfig(TripOption tripOption, double netPrice, double priceForChildren, RoomClass roomClass,
                         RoomTypex roomType, SailsTrip trip, double netPriceVND)
 {
     _tripOption = tripOption;
     //_netPrice = netPrice;
     _priceForChildren = priceForChildren;
     _roomClass        = roomClass;
     _roomType         = roomType;
     _trip             = trip;
     //_netPriceVND = netPriceVND;
 }
Пример #4
0
 public Booking(bool deleted, User createdBy, DateTime createdDate, User modifiedBy, DateTime modifiedDate,
                User partnerId, User saleId, DateTime startDate, StatusType status, TripOption tripOpion,
                SailsTrip trip)
 {
     _deleted      = deleted;
     _createdBy    = createdBy;
     _createdDate  = createdDate;
     _modifiedBy   = modifiedBy;
     _modifiedDate = modifiedDate;
     _partnerId    = partnerId;
     _saleId       = saleId;
     _startDate    = startDate;
     _status       = status;
     _tripOpion    = tripOpion;
     _trip         = trip;
 }
        /// <summary>
        /// Tính giá cho một loại phòng
        /// </summary>
        /// <returns></returns>
        public static double Calculate(RoomClass rclass, RoomTypex rtype, int adult, int child, bool isSingle, SailsTrip trip, Cruise cruise, TripOption option, DateTime startDate, SailsModule Module, IList policies, double childPrice, double agencySup, Agency agency)
        {
            // Lấy về bảng giá áp dụng cho thời điểm xuất phát
            if (trip == null)
            {
                return(0);
            }
            SailsPriceConfig priceConfig = Module.SailsPriceConfigGet(rclass, rtype, trip, cruise, option, startDate,
                                                                      BookingType.Double, agency);

            if (priceConfig == null)
            {
                throw new PriceException(string.Format("There isn't any price for {0} {1} room in trip {2} on {3}", rclass.Name, rtype.Name, trip.Name, startDate));
            }
            #region -- Giá phòng --
            double price;
            // Biến để lưu giá trị single supplement nếu là booking single
            double singlesup = 0;
            if (isSingle)
            {
                if (agencySup > 0)
                {
                    singlesup = agencySup;
                }
                else
                {
                    singlesup = priceConfig.SpecialPrice; //Module.ApplyPriceFor(priceConfig.SpecialPrice, policies);
                }
            }

            // Tính giá phòng theo người lớn

            // Đơn giá của phòng (đã áp dụng chính sách)
            double unitPrice;
            if (priceConfig.Table.Agency == null)
            {
                //unitPrice = Module.ApplyPriceFor(priceConfig.NetPrice, policies);
            }
            else
            {
                //unitPrice = priceConfig.NetPrice;
            }
            if (rtype.IsShared)
            {
                // Giá phòng twin phòng đơn giá x số lượng người lớn / 2 + đơn giá x tỉ lệ dành cho child x số child / 2
                // (Thực ra adult = 1/2, child =0/1)
                //price = unitPrice * adult / 2 + unitPrice * child * childPrice / 100 / 2;
                // Cộng thêm singlesup (nếu không phải single thì là + 0)
                //price += singlesup;
            }
            else
            {
                // Giá phòng double phòng đơn giá x số lượng người lớn / 2 + đơn giá x tỉ lệ dành cho child x số child / 2
                //price = unitPrice * adult / 2 + unitPrice * child * childPrice / 100 / 2;
                // Cộng thêm singlesup (nếu không phải single thì là + 0)
                //price += singlesup;
            }
            #endregion

            //return price;

            return(0.0);
        }
Пример #6
0
        /// <summary>
        /// Lấy về price config theo trip, room type và room class
        /// </summary>
        /// <param name="trip"></param>
        /// <param name="type"></param>
        /// <param name="roomClass"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public SailsPriceConfig SailsPriceConfigGetBy_RoomType_RoomClass_Trip(SailsTrip trip, RoomTypex type, RoomClass roomClass, TripOption option)
        {
            ICriteria criteria = _session.OpenSession().CreateCriteria(typeof(SailsPriceConfig));

            criteria.Add(Expression.Eq(SailsPriceConfig.TRIP, trip))
            .Add(Expression.Eq(SailsPriceConfig.ROOMTYPE, type))
            .Add(Expression.Eq(SailsPriceConfig.ROOMCLASS, roomClass))
            .Add(Expression.Eq(SailsPriceConfig.TRIPOPTION, option));
            criteria.AddOrder(new Order("Id", false));
            IList result = criteria.List();

            if (result.Count > 0)
            {
                return(result[0] as SailsPriceConfig);
            }
            return(null);
        }
Пример #7
0
        public static double RoomPrice(SailsModule module, RoomClass rclass, RoomTypex rtype, SailsTrip trip, Cruise cruise, TripOption option, DateTime startDate)
        {
            if (trip == null)
            {
                return(0);
            }
            SailsPriceConfig rolePrice = module.SailsPriceConfigGet(rclass, rtype, trip, cruise, option, startDate,
                                                                    BookingType.Double, null);

            if (rolePrice != null)
            {
                return(rolePrice.NetPrice);
            }

            SailsPriceConfig priceConfig = module.SailsPriceConfigGet2(rclass, rtype, trip, cruise, option, startDate, BookingType.Double, null);

            if (priceConfig != null)
            {
                return(priceConfig.NetPrice * MARK_UP);
            }

            return(-1);
        }
Пример #8
0
        protected void buttonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //Biến để đếm tổng số customer

                // Tạo đối tượng booking mới
                Booking     booking     = new Booking();
                CultureInfo cultureInfo = new CultureInfo("vi-VN");

                #region -- Các thông tin cơ bản --
                if (PageEngine.User.Identity is User)
                {
                    booking.CreatedBy  = (User)Page.User.Identity;
                    booking.ModifiedBy = (User)Page.User.Identity;
                    booking.Partner    = (User)Page.User.Identity;
                    //booking.Sale = (User)Page.User.Identity;
                }

                booking.CreatedDate  = DateTime.Now;
                booking.ModifiedDate = DateTime.Now;
                DateTime startDate = DateTime.ParseExact(Session["StartDate"].ToString(), "dd/MM/yyyy",
                                                         cultureInfo.DateTimeFormat);
                booking.StartDate = startDate;
                booking.Status    = StatusType.Cancelled;
                #endregion

                #region - Lấy trip và trip option đã book từ biến session -

                SailsTrip trip = Module.TripGetById(Convert.ToInt32(Session["TripId"]));
                booking.Trip = trip;

                TripOption tripOption = TripOption.Option1;
                if (!string.IsNullOrEmpty(Session["TripOption"].ToString()))
                {
                    tripOption = (TripOption)Convert.ToInt32(Session["TripOption"]);
                }

                booking.TripOption = tripOption;
                #endregion

                // Save booking lại
                if (panelCustomer.Visible)
                {
                    booking.Note = fckCustomers.Value;
                }

                if (liAnonymous.Visible)
                {
                    booking.Name  = txtYourName.Text;
                    booking.Email = txtEmail.Text;
                }

                booking.PickupAddress  = txtPickupAddress.Text;
                booking.SpecialRequest = txtSpecialRequest.Text;
                Module.Save(booking, null);

                #region -- Lấy thông tin về extra services từ session --
                // Mặc dù extra service đã được chọn từ form trước, tuy nhiên tại form này mới lưu lại thông tin booking
                // Do đó đến form này mới lấy lại thông tin extra service
                if (Session["ExtraService"] != null)
                {
                    string[] services = Session["ExtraService"].ToString().Split(',');
                    foreach (string serviceId in services)
                    {
                        ExtraOption  service        = Module.ExtraOptionGetById(Convert.ToInt32(serviceId));
                        BookingExtra bookingService = new BookingExtra();
                        bookingService.Booking     = booking;
                        bookingService.ExtraOption = service;
                        Module.Save(bookingService);
                    }
                }
                #endregion

                #region -- Lưu thông tin khách hàng --
                foreach (RepeaterItem item in rptRoomList.Items)
                {
                    // Đối với mỗi đối tượng trong room list
                    Label label_RoomId = (Label)item.FindControl("label_RoomId");

                    #region -- Thông tin về phòng --
                    HiddenField hiddenRoomClassId = (HiddenField)item.FindControl("hiddenRoomClassId");
                    HiddenField hiddenRoomTypeId  = (HiddenField)item.FindControl("hiddenRoomTypeId");

                    // Lấy về room id theo label Room id đã bound trước đó
                    int roomId = 0;
                    // Lấy ID của phòng nếu đã có phòng chọn (prefer room)
                    if (!string.IsNullOrEmpty(label_RoomId.Text))
                    {
                        roomId = Convert.ToInt32(label_RoomId.Text);
                    }
                    Room room = null;
                    if (roomId > 0)
                    {
                        room = Module.RoomGetById(roomId);
                    }
                    #endregion

                    #region -- Lấy thông tin khách hàng --
                    CheckBox checkBoxAddChild = (CheckBox)item.FindControl("checkBoxAddChild");
                    CheckBox checkBoxAddBaby  = (CheckBox)item.FindControl("checkBoxAddBaby");
                    CheckBox checkBoxSingle   = (CheckBox)item.FindControl("checkBoxSingle");

                    //TODO: CHECK THIS
                    //BookingType bookingType = (BookingType) Enum.Parse(typeof(BookingType),ddlRoomType.SelectedValue);
                    const BookingType bookingType   = BookingType.Double;
                    CustomerInfoInput customerInfo1 = (CustomerInfoInput)item.FindControl("customer1");
                    CustomerInfoInput customerInfo2 = (CustomerInfoInput)item.FindControl("customer2");

                    BookingRoom bookingRoom;
                    if (room != null)
                    {
                        bookingRoom = new BookingRoom(booking, room, room.RoomClass, room.RoomType);
                    }
                    else
                    {
                        RoomClass roomClass = Module.RoomClassGetById(Convert.ToInt32(hiddenRoomClassId.Value));
                        RoomTypex roomType  = Module.RoomTypexGetById(Convert.ToInt32(hiddenRoomTypeId.Value));
                        bookingRoom = new BookingRoom(booking, null, roomClass, roomType);
                    }
                    bookingRoom.BookingType = bookingType;
                    bookingRoom.HasBaby     = checkBoxAddBaby.Checked;
                    bookingRoom.HasChild    = checkBoxAddChild.Checked;
                    bookingRoom.IsSingle    = checkBoxSingle.Checked;
                    Module.Save(bookingRoom);
                    #endregion

                    #region -- Khách hàng --
                    Customer customer1;
                    Customer customer2;

                    Control trCustomer2 = item.FindControl("trCustomer2");

                    customer1             = customerInfo1.NewCustomer(Module);
                    customer1.BookingRoom = bookingRoom;
                    customer1.Booking     = booking;
                    customer1.Type        = CustomerType.Adult;
                    Module.Save(customer1);

                    if (bookingRoom.RoomType.Id != SailsModule.TWIN || trCustomer2.Visible)
                    {
                        customer2             = customerInfo2.NewCustomer(Module);
                        customer2.BookingRoom = bookingRoom;
                        customer2.Booking     = booking;
                        customer2.Type        = CustomerType.Adult;
                        Module.Save(customer2);
                    }

                    if (checkBoxAddChild.Checked)
                    {
                        CustomerInfoInput customerChild = (CustomerInfoInput)item.FindControl("customerChild");
                        Customer          child         = customerChild.NewCustomer(Module);
                        child.BookingRoom = bookingRoom;
                        child.Booking     = booking;
                        child.Type        = CustomerType.Children;
                        Module.Save(child);
                    }

                    if (checkBoxAddBaby.Checked)
                    {
                        CustomerInfoInput customerBaby = (CustomerInfoInput)item.FindControl("customerBaby");
                        Customer          baby         = customerBaby.NewCustomer(Module);
                        baby.BookingRoom = bookingRoom;
                        baby.Booking     = booking;
                        baby.Type        = CustomerType.Baby;
                        Module.Save(baby);
                    }

                    #endregion
                }
                #endregion

                Session.Add("Finish", booking.Id);

                // Chuyển sang trang kết thúc (trang confirm lại lần cuối booking)
                PageEngine.PageRedirect(string.Format("{0}/{1}{2}", UrlHelper.GetUrlFromSection(Module.Section),
                                                      SailsModule.ACTION_BOOKING_FINISH_PARAM,
                                                      UrlHelper.EXTENSION));
            }
            catch (Exception ex)
            {
                _logger.Error("Error when buttonSubmit_Click inCustomersInfo control", ex);
                throw;
            }
        }
 public TripAndOption(SailsTrip trip, TripOption option)
 {
     Trip   = trip;
     Option = option;
 }