示例#1
0
        public void BookingTrackSaveAddRoom()
        {
            BookingTrack track = new BookingTrack()
            {
                Booking      = Booking,
                ModifiedDate = DateTime.Now,
                User         = CurrentUser,
            };

            BookingChanged change = new BookingChanged()
            {
                Action    = BookingAction.AddRoom,
                Parameter = ddlRoomTypes.SelectedItem.Text,
                Track     = track,
            };

            Module.SaveOrUpdate(change);

            BookingChanged customerChange = new BookingChanged()
            {
                Action    = BookingAction.AddCustomer,
                Parameter = string.Format("{0}|{1}|{2}", 2, 0, 0),
                Track     = track,
            };

            Module.SaveOrUpdate(customerChange);
        }
 private void OnBookingChanged(Object sender, EventArgs args)
 {
     BookingChanged?.Invoke(sender, args);
 }
示例#3
0
 private void OnBookingChanged(BookingDTO booking)
 {
     BookingChanged?.Invoke(booking);
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckAvailable())
            {
                return;
            }

            // Kiểm tra số phòng đã chọn, nếu chưa chọn phòng nào thì thông báo yêu cầu
            if (_bookingRooms.Count <= 0 && !chkCharter.Checked)
            {
                ShowErrors("Hãy chọn ít nhất một phòng");
                return;
            }

            //2. Lưu thông tin phòng như thế nào
            // Dùng vòng lặp lưu thông tin đơn thuần, không có giá trị đi kèm nào cả

            // Phải lưu thông tin booking trước

            #region -- Booking --

            Booking booking  = new Booking();
            var     agencyId = -1;
            try
            {
                agencyId = Int32.Parse(agencySelector.Value);
            }
            catch { }
            booking.Agency       = AddBookingBLL.AgencyGetById(agencyId);
            booking.CreatedBy    = Page.User.Identity as User;
            booking.CreatedDate  = DateTime.Now;
            booking.ModifiedDate = DateTime.Now;
            booking.Partner      = null;
            booking.Sale         = booking.CreatedBy;
            booking.StartDate    = Date.Value;


            if (ApprovedDefault)
            {
                booking.Status = StatusType.Approved;
            }
            else
            {
                booking.Status = StatusType.Pending;
            }

            booking.Status = StatusType.Pending;

            if (TripBased)
            {
                booking.Trip = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue));
            }
            else
            {
                booking.Trip = null;
            }
            var cruise = null as Cruise;
            if (ViewState["cruiseId"] != null)
            {
                var cruiseIdViewState = (int)ViewState["cruiseId"];
                cruise = Module.GetObject <Cruise>(cruiseIdViewState);
            }
            booking.Cruise    = cruise;
            booking.IsCharter = chkCharter.Checked;
            booking.Total     = 0;

            // Xác định custom booking id
            if (UseCustomBookingId)
            {
                int maxId = Module.BookingGenerateCustomId(booking.StartDate);
                booking.Id = maxId;
            }

            //if (booking.Cruise.Name.Contains("Scorpio") && !booking.Cruise.Name.Contains("1"))
            //{
            //    booking.IsCharter = true;
            //}
            Module.Save(booking, UserIdentity);
            #endregion

            // Sau đó mới có thể lưu thông tin phòng
            // Đối với phòng có baby và child theo phân bố từ trước sẽ thêm child, baby

            #region -- Booking Room --
            foreach (BookingRoom room in _bookingRooms)
            {
                room.Book = booking;
                Module.Save(room);

                // Ngoài ra còn phải lưu thông tin khách hàng

                #region -- Thông tin khách hàng, suy ra từ thông tin phòng --

                for (int ii = 1; ii <= room.Booked; ii++)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Adult;
                    if (CustomerPrice)
                    {
                        customer.Total = room.Total / 2;
                    }
                    Module.Save(customer);
                }

                if (room.HasBaby)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Baby;
                    Module.Save(customer);
                }

                if (room.HasChild)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Children;
                    Module.Save(customer);
                }

                #endregion
            }

            #endregion

            #region -- Thông tin dịch vụ đi kèm --

            foreach (RepeaterItem serviceItem in rptExtraServices.Items)
            {
                //HiddenField hiddenValue = (HiddenField)serviceItem.FindControl("hiddenValue");
                HiddenField       hiddenId   = (HiddenField)serviceItem.FindControl("hiddenId");
                HtmlInputCheckBox chkService = (HtmlInputCheckBox)serviceItem.FindControl("chkService");
                if (chkService.Checked)
                {
                    ExtraOption  service = Module.ExtraOptionGetById(Convert.ToInt32(hiddenId.Value));
                    BookingExtra extra   = new BookingExtra();
                    extra.Booking     = booking;
                    extra.ExtraOption = service;
                    Module.Save(extra);
                }
            }

            #endregion

            #region -- Track thêm mới --

            BookingTrack track = new BookingTrack();
            track.Booking      = booking;
            track.ModifiedDate = DateTime.Now;
            track.User         = UserIdentity;
            Module.SaveOrUpdate(track);

            BookingChanged change = new BookingChanged();
            change.Action    = BookingAction.Created;
            change.Parameter = string.Format("{0}", booking.Total);
            change.Track     = track;
            Module.SaveOrUpdate(change);

            #endregion

            if (chkCharter.Checked)
            {
                var locked = new Locked();
                locked.Charter     = booking;
                locked.Cruise      = booking.Cruise;
                locked.Description = "Booking charter";
                locked.Start       = booking.StartDate;
                locked.End         = booking.EndDate;
                Module.SaveOrUpdate(locked);
            }

            //var smtpClient = new SmtpClient("mail.orientalsails.com", 26)
            //{
            //    Credentials = new NetworkCredential("*****@*****.**", "EGGaXBwuEWa+")

            //};

            //var message = new MailMessage
            //{
            //    From = new MailAddress("*****@*****.**"),
            //    IsBodyHtml = true,
            //    BodyEncoding = Encoding.UTF8,
            //    Body = "alooo",
            //    Subject = "CutOff Date Booking Reminder"
            //};

            //message.To.Add(new MailAddress("*****@*****.**"));
            //if (booking.BookingSale != null)
            //{
            //    if (booking.BookingSale.Sale != null)
            //    {
            //        message.To.Add(new MailAddress(booking.BookingSale.Sale.Email));
            //    }
            //}
            //smtpClient.Send(message);

            PageRedirect(string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}&Notify=0", Node.Id,
                                       Section.Id, booking.Id));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //2. Lưu thông tin phòng như thế nào
            // Dùng vòng lặp lưu thông tin đơn thuần, không có giá trị đi kèm nào cả

            // Phải lưu thông tin booking trước

            #region -- Booking --
            var     series  = Module.GetById <Series>(Convert.ToInt32(Request["si"]));
            Booking booking = new Booking();

            booking.CreatedBy      = Page.User.Identity as User;
            booking.CreatedDate    = DateTime.Now;
            booking.ModifiedDate   = DateTime.Now;
            booking.Partner        = null;
            booking.Sale           = booking.CreatedBy;
            booking.StartDate      = Date.Value;
            booking.SpecialRequest = txtSpecialRequest.Text;
            booking.AgencyCode     = txtAgencyCode.Text;
            booking.Agency         = series.Agency;
            booking.Booker         = series.Booker;
            //booking.Status = StatusType.Pending;
            booking.Total         = 0;
            booking.Series        = series;
            booking.PickupAddress = "N/A";
            booking.Deadline      = booking.StartDate.Subtract(new TimeSpan(series.CutoffDate, 0, 0, 0));

            if (TripBased)
            {
                booking.Trip = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue));
            }
            else
            {
                booking.Trip = null;
            }
            if (booking.Trip != null)
            {
                booking.EndDate = booking.StartDate.AddDays(booking.Trip.NumberOfDay - 1);
            }

            var cruise = null as Cruise;
            if (ViewState["cruiseId"] != null)
            {
                var cruiseIdViewState = (int)ViewState["cruiseId"];
                cruise = Module.GetObject <Cruise>(cruiseIdViewState);
            }
            booking.Cruise    = cruise;
            booking.IsCharter = chkCharter.Checked;
            booking.Total     = 0;

            // Xác định custom booking id
            if (UseCustomBookingId)
            {
                int maxId = Module.BookingGenerateCustomId(booking.StartDate);
                booking.Id = maxId;
            }

            //if (booking.Cruise.Name.Contains("Scorpio") && !booking.Cruise.Name.Contains("1"))
            //{
            //    booking.IsCharter = true;
            //}

            var statusType = (StatusType)Enum.Parse(typeof(StatusType), ddlStatusType.SelectedValue);
            booking.Status = statusType;
            if (statusType == StatusType.CutOff)
            {
                if (!string.IsNullOrWhiteSpace(txtCutOffDays.Text))
                {
                    booking.CutOffDays = Int32.Parse(txtCutOffDays.Text.Trim());
                }
            }
            if (statusType == StatusType.Pending)
            {
                //booking.Status = StatusType.Pending;
                if (!string.IsNullOrWhiteSpace(txtDeadline.Text))
                {
                    booking.Deadline = DateTime.ParseExact(txtDeadline.Text, "dd/MM/yyyy HH:mm",
                                                           CultureInfo.InvariantCulture);
                }
            }

            Module.Save(booking, UserIdentity);
            #endregion

            // Sau đó mới có thể lưu thông tin phòng
            // Đối với phòng có baby và child theo phân bố từ trước sẽ thêm child, baby
            GetBookingRoom();
            #region -- Booking Room --
            foreach (BookingRoom room in _bookingRooms)
            {
                room.Book = booking;
                Module.Save(room);

                // Ngoài ra còn phải lưu thông tin khách hàng

                #region -- Thông tin khách hàng, suy ra từ thông tin phòng --

                for (int ii = 1; ii <= room.Booked; ii++)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Adult;
                    if (CustomerPrice)
                    {
                        customer.Total = room.Total / 2;
                    }
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasBaby)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Baby;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasChild)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Children;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }
                Module.Save(room);
                #endregion
            }

            #endregion

            #region -- Thông tin dịch vụ đi kèm --

            foreach (RepeaterItem serviceItem in rptExtraServices.Items)
            {
                //HiddenField hiddenValue = (HiddenField)serviceItem.FindControl("hiddenValue");
                HiddenField       hiddenId   = (HiddenField)serviceItem.FindControl("hiddenId");
                HtmlInputCheckBox chkService = (HtmlInputCheckBox)serviceItem.FindControl("chkService");
                if (chkService.Checked)
                {
                    ExtraOption  service = Module.ExtraOptionGetById(Convert.ToInt32(hiddenId.Value));
                    BookingExtra extra   = new BookingExtra();
                    extra.Booking     = booking;
                    extra.ExtraOption = service;
                    Module.Save(extra);
                }
            }

            #endregion

            #region -- Track thêm mới --

            BookingTrack track = new BookingTrack();
            track.Booking      = booking;
            track.ModifiedDate = DateTime.Now;
            track.User         = UserIdentity;
            Module.SaveOrUpdate(track);

            BookingChanged change = new BookingChanged();
            change.Action    = BookingAction.Created;
            change.Parameter = string.Format("{0}", booking.Total);
            change.Track     = track;
            Module.SaveOrUpdate(change);

            #endregion

            if (chkCharter.Checked)
            {
                var locked = new Locked();
                locked.Charter     = booking;
                locked.Cruise      = booking.Cruise;
                locked.Description = "Booking charter";
                locked.Start       = booking.StartDate;
                locked.End         = booking.EndDate;
                Module.SaveOrUpdate(locked);
            }
            Page.ClientScript.RegisterStartupScript(this.GetType(), "RefreshParentPage", "RefreshParentPage();", true);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                // Kiểm tra thêm về phòng và thông tin đối tác
                if (!AllowNoAgency && agencySelector.SelectedAgency == null)
                {
                    ShowError("Chưa có thông tin đối tác");
                    return;
                }

                if (!Date.HasValue)
                {
                    ShowError("Phải có ngày khởi hành");
                    return;
                }

                //2. Lưu thông tin phòng như thế nào
                // Dùng vòng lặp lưu thông tin đơn thuần, không có giá trị đi kèm nào cả

                // Phải lưu thông tin booking trước
                #region -- Booking --
                Booking booking = new Booking();
                if (agencySelector.SelectedAgency != null)
                {
                    booking.Agency = agencySelector.SelectedAgency;
                }
                booking.CreatedBy    = Page.User.Identity as User;
                booking.CreatedDate  = DateTime.Now;
                booking.ModifiedDate = DateTime.Now;
                booking.Partner      = null;
                booking.Sale         = booking.CreatedBy;
                booking.StartDate    = Date.Value;
                if (ApprovedDefault)
                {
                    booking.Status = StatusType.Approved;
                }
                else
                {
                    booking.Status = StatusType.Pending;
                }
                if (TripBased)
                {
                    booking.Trip = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue));
                }
                else
                {
                    booking.Trip = null;
                }
                booking.Total = 0;

                Module.Save(booking, UserIdentity);

                #region -- Track thêm mới --
                BookingTrack track = new BookingTrack();
                track.Booking      = booking;
                track.ModifiedDate = DateTime.Now;
                track.User         = UserIdentity;
                Module.SaveOrUpdate(track);

                BookingChanged change = new BookingChanged();
                change.Action    = BookingAction.Created;
                change.Parameter = string.Format("{0}", booking.Total);
                change.Track     = track;
                Module.SaveOrUpdate(change);
                #endregion

                #region -- Thông tin dịch vụ đi kèm --
                foreach (RepeaterItem serviceItem in rptExtraServices.Items)
                {
                    //HiddenField hiddenValue = (HiddenField)serviceItem.FindControl("hiddenValue");
                    HiddenField hiddenId   = (HiddenField)serviceItem.FindControl("hiddenId");
                    CheckBox    chkService = (CheckBox)serviceItem.FindControl("chkService");
                    if (chkService.Checked)
                    {
                        ExtraOption  service = Module.ExtraOptionGetById(Convert.ToInt32(hiddenId.Value));
                        BookingExtra extra   = new BookingExtra();
                        extra.Booking     = booking;
                        extra.ExtraOption = service;
                        Module.Save(extra);
                    }
                }
                #endregion

                #endregion

                // Tạo danh sách khách theo booking
                int adult = 0;
                int child = 0;
                int baby  = 0;

                int totalAdult = ddlAdult.SelectedIndex;
                int totalChild = ddlChild.SelectedIndex;
                int totalBaby  = ddlBaby.SelectedIndex;

                while (adult < totalAdult)
                {
                    Customer customer = new Customer();
                    customer.Type    = CustomerType.Adult;
                    customer.Booking = booking;
                    Module.SaveOrUpdate(customer);
                    adult++;
                }

                while (child < totalChild)
                {
                    Customer customer = new Customer();
                    customer.Type    = CustomerType.Children;
                    customer.Booking = booking;
                    Module.SaveOrUpdate(customer);
                    child++;
                }

                while (baby < totalBaby)
                {
                    Customer customer = new Customer();
                    customer.Type    = CustomerType.Baby;
                    customer.Booking = booking;
                    Module.SaveOrUpdate(customer);
                    baby++;
                }

                PageRedirect(string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}&Notify=0", Node.Id, Section.Id, booking.Id));
            }
            catch (Exception ex)
            {
                ShowError("Error :" + ex.Message);
                _logger.Error(ex.Message, ex);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckAvailable())
            {
                return;
            }

            // Kiểm tra số phòng đã chọn, nếu chưa chọn phòng nào thì thông báo yêu cầu
            if (_bookingRooms.Count <= 0 && !chkCharter.Checked)
            {
                ShowErrors("Hãy chọn ít nhất một phòng");
                return;
            }

            //2. Lưu thông tin phòng như thế nào
            // Dùng vòng lặp lưu thông tin đơn thuần, không có giá trị đi kèm nào cả

            // Phải lưu thông tin booking trước

            #region -- Booking --

            Booking booking = new Booking();
            booking.CreatedBy    = Page.User.Identity as User;
            booking.CreatedDate  = DateTime.Now;
            booking.ModifiedDate = DateTime.Now;
            booking.Partner      = null;
            booking.Sale         = booking.CreatedBy;
            booking.StartDate    = Date.Value;


            if (ApprovedDefault)
            {
                booking.Status = StatusType.Approved;
            }
            else
            {
                booking.Status = StatusType.Pending;
            }

            booking.Status = StatusType.Pending;

            if (TripBased)
            {
                booking.Trip = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue));
            }
            else
            {
                booking.Trip = null;
            }
            var cruise = null as Cruise;
            if (ViewState["cruiseId"] != null)
            {
                var cruiseIdViewState = (int)ViewState["cruiseId"];
                cruise = Module.GetObject <Cruise>(cruiseIdViewState);
            }
            booking.Cruise    = cruise;
            booking.IsCharter = chkCharter.Checked;
            booking.Total     = 0;

            // Xác định custom booking id
            if (UseCustomBookingId)
            {
                int maxId = Module.BookingGenerateCustomId(booking.StartDate);
                booking.Id = maxId;
            }

            //if (booking.Cruise.Name.Contains("Scorpio") && !booking.Cruise.Name.Contains("1"))
            //{
            //    booking.IsCharter = true;
            //}

            // series
            var series = Module.GetById <Series>(Convert.ToInt32(Request["si"]));
            booking.Agency        = series.Agency;
            booking.Booker        = series.Booker;
            booking.Status        = StatusType.Pending;
            booking.Total         = 0;
            booking.Series        = series;
            booking.PickupAddress = "N/A";
            booking.Deadline      = booking.StartDate.Subtract(new TimeSpan(series.CutoffDate, 0, 0, 0));

            booking.AgencyCode     = txtAgencyCode.Text;
            booking.SpecialRequest = txtSpecialRequest.Text;

            var statusType = (StatusType)Enum.Parse(typeof(StatusType), ddlStatusType.SelectedValue);
            booking.Status = statusType;
            if (statusType == StatusType.CutOff)
            {
                if (!string.IsNullOrWhiteSpace(txtCutOffDays.Text))
                {
                    booking.CutOffDays = Int32.Parse(txtCutOffDays.Text.Trim());
                }
            }
            if (statusType == StatusType.Pending)
            {
                //booking.Status = StatusType.Pending;
                if (!string.IsNullOrWhiteSpace(txtDeadline.Text))
                {
                    booking.Deadline = DateTime.ParseExact(txtDeadline.Text, "dd/MM/yyyy HH:mm",
                                                           CultureInfo.InvariantCulture);
                }
            }

            Module.Save(booking, UserIdentity);
            #endregion

            // Sau đó mới có thể lưu thông tin phòng
            // Đối với phòng có baby và child theo phân bố từ trước sẽ thêm child, baby
            _roomCruises = Module.RoomGetAll2(booking.Cruise);
            var currentDayBookings = Module.GetBookingByDate(booking.StartDate, booking.Cruise);
            var nextDayBookings    = Module.GetBookingByDate(booking.StartDate.AddDays(1), booking.Cruise);

            var listRoomAvailable = new List <Room>();

            foreach (Room room in _roomCruises)
            {
                var bk = FindBooking(room, booking.StartDate, currentDayBookings);
                if (bk == null)
                {
                    if (booking.Trip != null && booking.Trip.NumberOfDay > 2)
                    {
                        var nextBk = FindBooking(room, booking.StartDate.AddDays(1), nextDayBookings);
                        if (nextBk == null)
                        {
                            listRoomAvailable.Add(room);
                        }
                    }
                    else
                    {
                        listRoomAvailable.Add(room);
                    }
                }
            }
            #region -- Booking Room --
            foreach (BookingRoom room in _bookingRooms)
            {
                var getRandomRoom = listRoomAvailable.First(r => r.RoomType.Id == room.RoomType.Id);
                room.Room = getRandomRoom;
                room.Book = booking;
                Module.Save(room);
                listRoomAvailable.Remove(getRandomRoom);
                // Ngoài ra còn phải lưu thông tin khách hàng

                #region -- Thông tin khách hàng, suy ra từ thông tin phòng --

                for (int ii = 1; ii <= room.Booked; ii++)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Adult;
                    if (CustomerPrice)
                    {
                        customer.Total = room.Total / 2;
                    }
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasBaby)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Baby;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasChild)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Children;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }
                Module.Save(room);
                #endregion
            }

            #endregion

            #region -- Thông tin dịch vụ đi kèm --

            foreach (RepeaterItem serviceItem in rptExtraServices.Items)
            {
                //HiddenField hiddenValue = (HiddenField)serviceItem.FindControl("hiddenValue");
                HiddenField       hiddenId   = (HiddenField)serviceItem.FindControl("hiddenId");
                HtmlInputCheckBox chkService = (HtmlInputCheckBox)serviceItem.FindControl("chkService");
                if (chkService.Checked)
                {
                    ExtraOption  service = Module.ExtraOptionGetById(Convert.ToInt32(hiddenId.Value));
                    BookingExtra extra   = new BookingExtra();
                    extra.Booking     = booking;
                    extra.ExtraOption = service;
                    Module.Save(extra);
                }
            }

            #endregion

            #region -- Track thêm mới --

            BookingTrack track = new BookingTrack();
            track.Booking      = booking;
            track.ModifiedDate = DateTime.Now;
            track.User         = UserIdentity;
            Module.SaveOrUpdate(track);

            BookingChanged change = new BookingChanged();
            change.Action    = BookingAction.Created;
            change.Parameter = string.Format("{0}", booking.Total);
            change.Track     = track;
            Module.SaveOrUpdate(change);

            #endregion

            if (chkCharter.Checked)
            {
                var locked = new Locked();
                locked.Charter     = booking;
                locked.Cruise      = booking.Cruise;
                locked.Description = "Booking charter";
                locked.Start       = booking.StartDate;
                locked.End         = booking.EndDate;
                Module.SaveOrUpdate(locked);
            }

            //var smtpClient = new SmtpClient("mail.orientalsails.com", 26)
            //{
            //    Credentials = new NetworkCredential("*****@*****.**", "EGGaXBwuEWa+")

            //};

            //var message = new MailMessage
            //{
            //    From = new MailAddress("*****@*****.**"),
            //    IsBodyHtml = true,
            //    BodyEncoding = Encoding.UTF8,
            //    Body = "alooo",
            //    Subject = "CutOff Date Booking Reminder"
            //};

            //message.To.Add(new MailAddress("*****@*****.**"));
            //if (booking.BookingSale != null)
            //{
            //    if (booking.BookingSale.Sale != null)
            //    {
            //        message.To.Add(new MailAddress(booking.BookingSale.Sale.Email));
            //    }
            //}
            //smtpClient.Send(message);

            //            PageRedirect(string.Format("BookingView.aspx?NodeId={0}&SectionId={1}&bi={2}&Notify=0", Node.Id,
            //                Section.Id, booking.Id));
            Page.ClientScript.RegisterStartupScript(this.GetType(), "RefreshParentPage", "RefreshParentPage();", true);
        }
示例#8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //2. Lưu thông tin phòng như thế nào
            // Dùng vòng lặp lưu thông tin đơn thuần, không có giá trị đi kèm nào cả

            // Phải lưu thông tin booking trước

            #region -- Booking --



            #endregion

            // Sau đó mới có thể lưu thông tin phòng
            // Đối với phòng có baby và child theo phân bố từ trước sẽ thêm child, baby
            GetBookingRoom();

            #region -- Booking Room --

            foreach (BookingRoom room in _bookingRooms)
            {
                room.Book = _booking;
                Module.Save(room);

                // Ngoài ra còn phải lưu thông tin khách hàng

                #region -- Thông tin khách hàng, suy ra từ thông tin phòng --

                for (int ii = 1; ii <= room.Booked; ii++)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Adult;
                    if (CustomerPrice)
                    {
                        customer.Total = room.Total / 2;
                    }
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasBaby)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Baby;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }

                if (room.HasChild)
                {
                    Customer customer = new Customer();
                    customer.BookingRoom = room;
                    customer.Type        = CustomerType.Children;
                    Module.Save(customer);
                    room.Customers.Add(customer);
                }
                Module.Save(room);

                #endregion
            }

            #endregion

            #region -- Track thêm mới --

            BookingTrack track = new BookingTrack();
            track.Booking      = _booking;
            track.ModifiedDate = DateTime.Now;
            track.User         = UserIdentity;
            Module.SaveOrUpdate(track);

            BookingChanged change = new BookingChanged();
            change.Action    = BookingAction.Created;
            change.Parameter = string.Format("{0}", _booking.Total);
            change.Track     = track;
            Module.SaveOrUpdate(change);

            #endregion
            Page.ClientScript.RegisterStartupScript(this.GetType(), "RefreshParentPage", "RefreshParentPage();", true);
        }