コード例 #1
0
 public void ClearSeachedTours()
 {
     RepFindedTours.DataSource = null;
     RepFindedTours.DataBind();
     RepPagesTop.DataSource = null;
     RepPagesTop.DataBind();
     RepPagesBottom.DataSource = null;
     RepPagesBottom.DataBind();
     SearchPages.Clear();
     CurrentPage = 0;
 }
コード例 #2
0
        protected void HeaderCol_OnCommand(object sender, CommandEventArgs e)
        {
            var linkButton = sender as LinkButton;

            if (linkButton == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (e.CommandName != "Sort")
            {
                return;
            }

            var column = (SortingColumn)Enum.Parse(typeof(SortingColumn), e.CommandArgument.ToString());

            if (column == CurrentSort.Item1)
            {
                CurrentSort = new Tuple <SortingColumn, SortingDirection>(CurrentSort.Item1,
                                                                          CurrentSort.Item2 == SortingDirection.Asc ? SortingDirection.Desc : SortingDirection.Asc);
            }
            else
            {
                CurrentSort = new Tuple <SortingColumn, SortingDirection>(column, SortingDirection.Asc);
            }

            using (var mtmDc = new MtMainDbDataContext())
            {
                using (var dc = new MtSearchDbDataContext())
                {
                    var searchResult = dc.PagingOnClient(mtmDc, CityKeyFrom.Value, CountryKey.Value, TourKeys, TourDates,
                                                         TourNights,
                                                         HotelKeys, PansionKeys, MainPlaces, AddPlaces, FirstChildYears, SecondChildYears, RoomTypeKeys,
                                                         HotelQuotaMask, AviaQuotaMask | QuotesStates.None, RateKey.Value, MaxTourPrice, RowsPerPage,
                                                         SearchPages[CurrentPage],
                                                         CurrentSort);

                    RepFindedTours.DataSource = searchResult.SearchItems;
                    RepFindedTours.DataBind();
                }
            }

            Web.ScrollToElement(this, RepPagesTop.ClientID);
            linkButton.Focus();
        }
コード例 #3
0
        protected void RepPagesItem_Command(object sender, CommandEventArgs e)
        {
            var linkButton = sender as LinkButton;

            if (linkButton == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            using (var mtmDc = new MtMainDbDataContext())
            {
                using (var mtsDc = new MtSearchDbDataContext())
                {
                    switch (e.CommandName)
                    {
                    case "PreviosPage":
                        CurrentPage--;
                        break;

                    case "PageToGo":
                        CurrentPage = uint.Parse(e.CommandArgument.ToString());
                        break;

                    case "NextPage":
                        CurrentPage++;
                        break;

                    default:
// ReSharper disable once NotResolvedInText
                        throw new ArgumentOutOfRangeException("e.CommandName", e.CommandName,
                                                              "Событие получено от незарегестрированого элемента.");
                    }

                    if (1 > CurrentPage || CurrentPage > SearchPages.Count)
                    {
                        throw new IndexOutOfRangeException(
                                  String.Format("Индекс текущей страницы поиска вышел за границы диапозона - {0}", CurrentPage));
                    }

                    var searchResult = mtsDc.PagingOnClient(mtmDc, CityKeyFrom.Value, CountryKey.Value, TourKeys, TourDates,
                                                            TourNights,
                                                            HotelKeys, PansionKeys, MainPlaces, AddPlaces, FirstChildYears, SecondChildYears,
                                                            RoomTypeKeys,
                                                            HotelQuotaMask, AviaQuotaMask | QuotesStates.None, RateKey.Value, MaxTourPrice, RowsPerPage,
                                                            SearchPages[CurrentPage],
                                                            CurrentSort);

                    CurrentSort = searchResult.SortType;

                    if (searchResult.IsMorePages && !SearchPages.ContainsKey(CurrentPage + 1))
                    {
                        SearchPages.Add(CurrentPage + 1, searchResult.NextPageRowCounter);
                    }

                    RepPagesTop.DataSource = SearchPages;
                    RepPagesTop.DataBind();
                    RepPagesBottom.DataSource = SearchPages;
                    RepPagesBottom.DataBind();

                    RepFindedTours.DataSource = searchResult.SearchItems;
                    RepFindedTours.DataBind();

                    Web.ScrollToElement(this, RepPagesTop.ClientID);
                    linkButton.Focus();
                }
            }
        }
コード例 #4
0
        public void ShowTours(int cityKeyFrom, int countryKey, int[] tourKeys,
                              DateTime[] tourDates, int[] tourNights, int[] hotelKeys,
                              int[] pansionKeys, ushort?mainPlaces, ushort?addPlaces, ushort?firstChildYears,
                              ushort?secondChildYears, int[] roomTypeKeys, QuotesStates hotelQuotaMask, QuotesStates aviaQuotaMask,
                              int rateKey, uint?maxTourPrice, ushort rowsPerPage)
        {
            if (tourKeys == null || !tourKeys.Any())
            {
                throw new ArgumentNullException("tourKeys");
            }
            if (tourDates == null || !tourDates.Any())
            {
                throw new ArgumentNullException("tourDates");
            }
            if (tourNights == null || !tourNights.Any())
            {
                throw new ArgumentNullException("tourNights");
            }
            if (hotelKeys == null || !hotelKeys.Any())
            {
                throw new ArgumentNullException("hotelKeys");
            }
            if (pansionKeys == null || !pansionKeys.Any())
            {
                throw new ArgumentNullException("pansionKeys");
            }
            if ((roomTypeKeys != null && roomTypeKeys.Any() && mainPlaces.HasValue) || ((roomTypeKeys == null || !roomTypeKeys.Any()) && !mainPlaces.HasValue))
            {
                throw new ArgumentException("Одноверменно не могут быть указаны значение количество взрослых и тип номера", "roomTypeKeys");
            }
            if (addPlaces > 0 && !firstChildYears.HasValue)
            {
                throw new ArgumentNullException("firstChildYears", "Не указан возраст первого ребенка");
            }
            if (addPlaces > 1 && !secondChildYears.HasValue)
            {
                throw new ArgumentNullException("secondChildYears", "Не указан возраст второго ребенка");
            }

            CityKeyFrom      = cityKeyFrom;
            CountryKey       = countryKey;
            TourKeys         = tourKeys;
            TourDates        = tourDates;
            TourNights       = tourNights;
            HotelKeys        = hotelKeys;
            PansionKeys      = pansionKeys;
            MainPlaces       = mainPlaces;
            AddPlaces        = addPlaces;
            FirstChildYears  = firstChildYears;
            SecondChildYears = secondChildYears;
            RoomTypeKeys     = roomTypeKeys;
            HotelQuotaMask   = hotelQuotaMask;
            AviaQuotaMask    = aviaQuotaMask;
            RateKey          = rateKey;
            MaxTourPrice     = maxTourPrice;
            RowsPerPage      = rowsPerPage;

            using (var mtmDc = new MtMainDbDataContext())
            {
                using (var mtsDc = new MtSearchDbDataContext())
                {
                    var searchResult = mtsDc.PagingOnClient(mtmDc, CityKeyFrom.Value, CountryKey.Value, TourKeys, TourDates,
                                                            TourNights,
                                                            HotelKeys, PansionKeys, MainPlaces, AddPlaces, FirstChildYears, SecondChildYears,
                                                            RoomTypeKeys,
                                                            HotelQuotaMask, AviaQuotaMask | QuotesStates.None, RateKey.Value, MaxTourPrice, RowsPerPage, 0, CurrentSort);

                    CurrentSort = searchResult.SortType;
                    SearchPages.Clear();

                    if (!searchResult.SearchItems.Any())
                    {
                        LtMessage.Text =
                            @"<div id='SearchResultsMsg' class='TFS_SearchResultsMsg'><span>К сожалению по вашему запросу ничего не найдено. Попробуйте изменить параметры поиска. Например квоты или количество едущих людей и т.д.</span></div>";
                        Web.ShowMessage(this,
                                        @"К сожалению по вашему запросу ничего не найдено. Попробуйте изменить параметры поиска. Например квоты или количество едущих людей и т.д.");
                        Web.ScrollToElement(this, "SearchResultsMsg");

                        //koshelev
                        //сделал обработку того, что ни один тур не найден
                        RepFindedTours.DataSource = null;
                        RepFindedTours.DataBind();

                        RepPagesTop.DataSource = null;
                        RepPagesTop.DataBind();
                        RepPagesBottom.DataSource = null;
                        RepPagesBottom.DataBind();
                        return;
                    }

                    LtMessage.Text = String.Empty;

                    // добовляем первую страницу
                    SearchPages.Add(1, 0);
                    CurrentPage = 1;

                    // инициализируем следующую страницу
                    if (searchResult.IsMorePages)
                    {
                        SearchPages.Add(CurrentPage + 1, searchResult.NextPageRowCounter);
                    }

                    RepPagesTop.DataSource = SearchPages;
                    RepPagesTop.DataBind();
                    RepPagesBottom.DataSource = SearchPages;
                    RepPagesBottom.DataBind();

                    RepFindedTours.DataSource = searchResult.SearchItems;
                    RepFindedTours.DataBind();
                }
            }
        }