protected void CheckInDateText_OnTextChanged(object sender, EventArgs e)
        {
            CheckInDateLink.CssClass += " update";

            int  ticketAvailable;
            bool availableProduct = PublicBooking.CheckinDate == null ||
                                    DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).AddDays(2).Date <= PublicBooking.CheckinDate.Value;

            var param = new CheckAvailableProductParams
            {
                ProductId   = PublicProduct.ProductId,
                CheckInDate = _selectedCheckInDate,
                TotalTicket = PublicBooking.Quantity,
                BookingId   = PublicBooking.BookingId,
                IsAdmin     = false,
                TimezoneId  = PublicHotel.TimeZoneId
            };

            availableProduct &= _productRepository.CheckAvailableProduct(param, out ticketAvailable);

            if (!availableProduct)
            {
                Session.Remove("CheckInDate" + PublicBooking.BookingId);
                CheckInDateLink.Text     = "SELECT<br/>CHECK-IN DATE";
                CheckInDateLink.CssClass = "select-checkin-date";
                ScriptManager.RegisterStartupScript(CheckInDateChangePanel, CheckInDateChangePanel.GetType(), "Update_Not_Available", "$(function(){$('#updateFail').modal('show');});", true);
                return;
            }

            ScriptManager.RegisterStartupScript(CheckInDateChangePanel, CheckInDateChangePanel.GetType(), "ConfirmUpdate", "$(function(){$('#confirmUpdate').modal('show');});", true);
        }
        protected void CheckInDateLink_OnClick(object sender, EventArgs e)
        {
            int  ticketAvailable;
            bool availableProduct = PublicBooking.CheckinDate == null ||
                                    DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).AddDays(2).Date <= PublicBooking.CheckinDate.Value;
            var param = new CheckAvailableProductParams
            {
                ProductId   = PublicProduct.ProductId,
                CheckInDate = _selectedCheckInDate,
                TotalTicket = PublicBooking.Quantity,
                BookingId   = PublicBooking.BookingId,
                IsAdmin     = false,
                TimezoneId  = PublicHotel.TimeZoneId
            };

            availableProduct &= _productRepository.CheckAvailableProduct(param, out ticketAvailable);

            if (!availableProduct)
            {
                Session.Remove("CheckInDate" + PublicBooking.BookingId);
                CheckInDateLink.Text     = "SELECT<br/>CHECK-IN DATE";
                CheckInDateLink.CssClass = "select-checkin-date";
                ScriptManager.RegisterStartupScript(CheckInDateChangePanel, CheckInDateChangePanel.GetType(), "Update_Not_Available", "$(function(){$('#updateFail').modal('show');});", true);
                return;
            }

            var  logs     = new CustomerCreditLogs();
            bool isRefund = false;

            try
            {
                if (!PublicBooking.HasInvoice)
                {
                    MaintainOldInvoices();
                }

                var newPrice = _productRepository.GetById(PublicProduct.ProductId, _selectedCheckInDate).ActualPriceWithDate;

                double actualPrice = GetActualPrice(newPrice);

                double diffPrice = actualPrice * PublicBooking.Quantity - PublicBooking.TotalPrice;

                // Charge
                if (diffPrice > 0)
                {
                    Charges(diffPrice, newPrice, actualPrice);

                    PublicBooking.TotalPrice   += diffPrice;
                    PublicBooking.HotelPrice    = actualPrice;
                    PublicBooking.MerchantPrice = newPrice.Price;
                }
                else if (diffPrice < 0) //Refund
                {
                    double payByCard = Math.Abs(diffPrice) - PublicBooking.PayByCredit;
                    if (PublicBooking.PayByCredit > 0)
                    {
                        var market = (from mh in _productRepository.MarketHotelList
                                      join m in _productRepository.MarketList on mh.MarketId equals m.Id
                                      where mh.HotelId == PublicHotel.HotelId
                                      select m).FirstOrDefault();
                        logs = new CustomerCreditLogs
                        {
                            CustomerId = PublicCustomerInfos != null
                                ? PublicCustomerInfos.CustomerId
                                : PublicBooking.CustomerId,
                            ProductId   = PublicBooking.ProductId,
                            Description = string.Format("{0} – {1} – {2} – {3}",
                                                        PublicProduct.ProductName,
                                                        PublicHotel.HotelName,
                                                        market != null ? market.LocationName : "",
                                                        PublicBooking.BookingIdString),
                            CreatedBy   = PublicCustomerInfos != null ? PublicCustomerInfos.CustomerId : 0,
                            CreatedDate = DateTime.UtcNow,
                            CreditType  = payByCard >= 0
                                ? (byte)Enums.CreditType.FullPurchaseRefund
                                : (byte)Enums.CreditType.PartialPuchaseRefund,
                            ReferralId = 0,
                            BookingId  = PublicBooking.BookingId,
                            Status     = true,
                            GiftCardId = 0
                        };
                        PublicBooking.PaymentType = (byte)Enums.PaymentType.DayAxeCredit;

                        // Refund All of Credit Used
                        if (payByCard >= 0)
                        {
                            PublicBooking.PayByCredit = 0;
                        }
                        else
                        {
                            PublicBooking.PayByCredit -= Math.Abs(diffPrice);
                        }
                    }

                    // Refund More with Stripe
                    if (payByCard > 0)
                    {
                        Refund(payByCard, new KeyValuePair <double, double>(PublicBooking.MerchantPrice, 0),
                               PublicBooking.HotelPrice);

                        PublicBooking.PaymentType = (byte)Enums.PaymentType.Stripe;

                        var        cardService = new StripeCardService();
                        StripeCard stripeCard  = cardService.Get(PublicCustomerInfos.StripeCustomerId,
                                                                 PublicCustomerInfos.StripeCardId);
                        StripeCardString = string.Format("{0} {1}", stripeCard.Brand, stripeCard.Last4);
                    }

                    PublicBooking.TotalPrice   += diffPrice;
                    PublicBooking.HotelPrice    = actualPrice;
                    PublicBooking.MerchantPrice = newPrice.Price;
                    isRefund = true;

                    PublicBooking.StripeCardString = StripeCardString;
                    _bookingRepository.RefundBooking(PublicBooking, logs);
                }
                else
                {
                    PublicBooking.TotalPrice   += diffPrice;
                    PublicBooking.HotelPrice    = actualPrice;
                    PublicBooking.MerchantPrice = newPrice.Price;
                }
            }
            catch (Exception ex)
            {
                UpdateNotPossibleLit.Text = ex.Message;
                ScriptManager.RegisterStartupScript(CheckInDateChangePanel, CheckInDateChangePanel.GetType(), "UpdateFail", "$(function(){$('#updateFail').modal('show');});", true);
                return;
            }

            PublicBooking.CheckinDate = _selectedCheckInDate.AddHours(Math.Abs(PublicHotel.TimeZoneOffset));
            PublicBooking.ExpiredDate = _selectedCheckInDate.AddDays(1).AddHours(Math.Abs(PublicHotel.TimeZoneOffset));
            if (isRefund)
            {
                _bookingRepository.Update(PublicBooking);
            }
            else
            {
                _bookingRepository.Update(PublicBooking, 0, logs);
            }

            Session.Remove("CheckInDate" + PublicBooking.BookingId);
            BindExpiredDate();
            CacheLayer.ClearAll();
            updateSuccess.Visible    = true;
            CheckInDateLink.Text     = "SELECT<br/>CHECK-IN DATE";
            CheckInDateLink.CssClass = "select-checkin-date";
            ScriptManager.RegisterStartupScript(CheckInDateChangePanel, CheckInDateChangePanel.GetType(), "ConfirmUpdate", "$(function(){$('#updateSuccess').modal('show');});", true);
        }