//Производит сортировку
 private void Sort()
 {
     if (SortText != "")
     {
         Fonbet    = new ObservableCollection <SiteRow>(FonbetData.Where(x => x.Sport.Contains(SortText)).OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Olimp     = new ObservableCollection <SiteRow>(OlimpData.Where(x => x.Sport.Contains(SortText)).OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Marafon   = new ObservableCollection <SiteRow>(MarafonData.Where(x => x.Sport.Contains(SortText)).OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Zenit     = new ObservableCollection <SiteRow>(ZenitData.Where(x => x.Sport.Contains(SortText)).OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         PariMatch = new ObservableCollection <SiteRow>(PariMatchData.Where(x => x.Sport.Contains(SortText)).OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
     }
     else
     {
         Fonbet    = new ObservableCollection <SiteRow>(FonbetData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Olimp     = new ObservableCollection <SiteRow>(OlimpData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Marafon   = new ObservableCollection <SiteRow>(MarafonData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         Zenit     = new ObservableCollection <SiteRow>(ZenitData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
         PariMatch = new ObservableCollection <SiteRow>(PariMatchData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
     }
 }
 private void FonbetSkip()
 {
     FonbetData.Remove(FonbetSelected);
     Fonbet.Remove(FonbetSelected);
 }
        //Добавляем данные из нижнего списка
        private void Add(object id)
        {
            string siteName = id.ToString();

            UnicData dt = null;

            if (siteName == "Fonbet")
            {
                if (FonbetSelected == null)
                {
                    MessageBox.Show("Выбирете, что-нибудь");
                    return;
                }
                dt = new UnicData(FonbetId, FonbetSelected.TeamName, StaticData.Shared.Enums.ParserType.Fonbet);
                FonbetData.Remove(FonbetSelected);
                Fonbet.Remove(FonbetSelected);
            }

            else if (siteName == "Olimp")
            {
                if (OlimpSelected == null)
                {
                    MessageBox.Show("Выбирете, что-нибудь");
                    return;
                }

                dt = new UnicData(OlimpId, OlimpSelected.TeamName, StaticData.Shared.Enums.ParserType.Olimp);
                OlimpData.Remove(OlimpSelected);
                Olimp.Remove(OlimpSelected);
            }

            else if (siteName == "Marafon")
            {
                if (MarafonSelected == null)
                {
                    MessageBox.Show("Выбирете, что-нибудь");
                    return;
                }

                dt = new UnicData(MarafonId, MarafonSelected.TeamName, StaticData.Shared.Enums.ParserType.Marafon);
                MarafonData.Remove(MarafonSelected);
                Marafon.Remove(MarafonSelected);
            }
            else if (siteName == "Zenit")
            {
                if (ZenitSelected == null)
                {
                    MessageBox.Show("Выбирете, что-нибудь");
                    return;
                }

                dt = new UnicData(ZenitId, ZenitSelected.TeamName, StaticData.Shared.Enums.ParserType.Zenit);
                ZenitData.Remove(ZenitSelected);
                Zenit.Remove(ZenitSelected);
            }

            else if (siteName == "PariMatch")
            {
                if (PariMacthSelected == null)
                {
                    MessageBox.Show("Выбирете, что-нибудь");
                    return;
                }

                dt = new UnicData(PariMatchId, PariMacthSelected.TeamName, StaticData.Shared.Enums.ParserType.PariMatch);
                PariMatchData.Remove(PariMacthSelected);
                PariMatch.Remove(PariMacthSelected);
            }

            Base.Add(dt);
        }
        //Делет добавление в базу выделенных элементов
        private void Adding()
        {
            int id = 1;

            if (Base.Count != 0)
            {
                id = Base.Select(x => x.Id).Max();
                id++;
            }

            //Это для работы базы с чистого листа
            if (id != 1)
            {
                //Проверяем есть ли такой элемент уже в базе.
                int temp = 0;
                if (FonbetSelected != null)
                {
                    temp = CheckValue(FonbetSelected.TeamName);
                }
                if (OlimpSelected != null && temp == 0)
                {
                    temp = CheckValue(OlimpSelected.TeamName);
                }
                if (MarafonSelected != null && temp == 0)
                {
                    temp = CheckValue(MarafonSelected.TeamName);
                }
                if (ZenitSelected != null && temp == 0)
                {
                    temp = CheckValue(ZenitSelected.TeamName);
                }
                if (PariMacthSelected != null && temp == 0)
                {
                    temp = CheckValue(PariMacthSelected.TeamName);
                }
                if (temp != 0)
                {
                    id = temp;
                }
            }

            //Создаем записи для нужных элементов
            if (FonbetSelected != null)
            {
                Base.Add(new UnicData(id, FonbetSelected.TeamName, StaticData.Shared.Enums.ParserType.Fonbet));
            }
            if (OlimpSelected != null)
            {
                Base.Add(new UnicData(id, OlimpSelected.TeamName, StaticData.Shared.Enums.ParserType.Olimp));
            }
            if (MarafonSelected != null)
            {
                Base.Add(new UnicData(id, MarafonSelected.TeamName, StaticData.Shared.Enums.ParserType.Marafon));
            }
            if (ZenitSelected != null)
            {
                Base.Add(new UnicData(id, ZenitSelected.TeamName, StaticData.Shared.Enums.ParserType.Zenit));
            }
            if (PariMacthSelected != null)
            {
                Base.Add(new UnicData(id, PariMacthSelected.TeamName, StaticData.Shared.Enums.ParserType.PariMatch));
            }

            //Удаляем из источника данных
            FonbetData.Remove(FonbetSelected);
            OlimpData.Remove(OlimpSelected);
            MarafonData.Remove(MarafonSelected);
            ZenitData.Remove(ZenitSelected);
            PariMatchData.Remove(PariMacthSelected);

            //Удаляем из отображаемой коллекции
            Fonbet.Remove(FonbetSelected);
            Olimp.Remove(OlimpSelected);
            Marafon.Remove(MarafonSelected);
            Zenit.Remove(ZenitSelected);
            PariMatch.Remove(PariMacthSelected);

            Clear();
        }
        private void LoadData()
        {
            try
            {
                FonbetData    = SiteRow.Load("Fonbet.data");
                OlimpData     = SiteRow.Load("Olimp.data");
                MarafonData   = SiteRow.Load("Marafon.data");
                ZenitData     = SiteRow.Load("Zenit.data");
                PariMatchData = SiteRow.Load("PariMatch.data");
                Base          = new ObservableCollection <UnicData>(UnicData.Load("bd.data").OrderBy(x => x.Id));
            }
            catch
            {
                Base = new ObservableCollection <UnicData>();
            }

            Base.CollectionChanged += Base_CollectionChanged;

            if (Base.Count != 0)
            {
                foreach (UnicData key in Base)
                {
                    foreach (SiteRow t in FonbetData)
                    {
                        if (t.TeamName == key.Value)
                        {
                            t.IsUsed = true;
                        }
                    }

                    foreach (SiteRow t in OlimpData)
                    {
                        if (t.TeamName == key.Value)
                        {
                            t.IsUsed = true;
                        }
                    }

                    foreach (SiteRow t in MarafonData)
                    {
                        if (t.TeamName == key.Value)
                        {
                            t.IsUsed = true;
                        }
                    }

                    foreach (SiteRow t in ZenitData)
                    {
                        if (t.TeamName == key.Value)
                        {
                            t.IsUsed = true;
                        }
                    }

                    foreach (SiteRow t in PariMatchData)
                    {
                        if (t.TeamName == key.Value)
                        {
                            t.IsUsed = true;
                        }
                    }
                }
            }

            Fonbet    = new ObservableCollection <SiteRow>(FonbetData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
            Olimp     = new ObservableCollection <SiteRow>(OlimpData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
            Marafon   = new ObservableCollection <SiteRow>(MarafonData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
            Zenit     = new ObservableCollection <SiteRow>(ZenitData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
            PariMatch = new ObservableCollection <SiteRow>(PariMatchData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart));
        }