Пример #1
0
        /// <summary>
        /// Переносим команды в левую часть
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLeft_Click(object sender, RoutedEventArgs e)
        {
            for (int n = 0; n < TeamsForReport.Count;)
            {
                CTeamForReportItem TeamForReport = TeamsForReport[n];
                for (int m = 0; m < TeamForReport.Subteams.Count;)
                {
                    CTeamItem TeamR = TeamForReport.Subteams[m];
                    if (TeamR.IsSelected)
                    {   // Переносим команду влево
                        TeamForReport.Subteams.RemoveAt(m);
                        TeamR.IsSelected = false;
                        Teams.Add(TeamR);
                    }
                    else
                    {
                        m++;
                    }
                }

                if (TeamForReport.Subteams.Count == 0)
                {
                    TeamsForReport.RemoveAt(n);
                }
                else
                {
                    n++;
                }
            }

            Teams = new ObservableCollection <CTeamItem>(Teams.OrderBy(arg => arg.Name));
        }
Пример #2
0
        public CTeamExportTab(CExportToExcelWnd ParentWnd, ObservableDictionary <long, CKeyValuePairEx <long, CCompSettings> > CompGroups) :
            base(ParentWnd, CompGroups)
        {
            InitializeComponent();

            lock (DBManagerApp.m_AppSettings.m_SettingsSyncObj)
            {
                AppSettings settings = DBManagerApp.m_AppSettings.m_Settings;

                foreach (groups gr1 in CompDesc.groups)
                {
                    CKeyValuePairEx <long, CCompSettings> GroupInfo;
                    if (CompGroups.TryGetValue(gr1.id_group, out GroupInfo))
                    {
                        switch (GroupInfo.Value.SecondColNameType)
                        {
                        case enSecondColNameType.Team:
                            // Добавляем в Teams тех команд, которых там нет
                            foreach (teams team in (from part in gr1.participations
                                                    join tm in DBManagerApp.m_Entities.teams on part.team equals tm.id_team
                                                    join tm2 in Teams on tm.id_team equals tm2.id into allTeams
                                                    from tm2 in allTeams.DefaultIfEmpty()
                                                    where tm2 == null
                                                    select tm).Distinct().ToList())
                            {
                                Teams.Add(new CTeamItem(team.id_team)
                                {
                                    Name = team.name
                                });
                            }
                            break;

                        case enSecondColNameType.Coach:
                            // Добавляем в Teams тех команд, которых там нет
                            foreach (coaches coach in (from part in gr1.participations
                                                       join coach in DBManagerApp.m_Entities.coaches on part.coach equals coach.id_coach
                                                       join coach2 in Teams on coach.id_coach equals coach2.id into allCoaches
                                                       from coach2 in allCoaches.DefaultIfEmpty()
                                                       where coach2 == null
                                                       select coach).Distinct().ToList())
                            {
                                Teams.Add(new CTeamItem(coach.id_coach)
                                {
                                    Name = coach.name
                                });
                            }
                            break;
                        }
                    }
                }
                Teams = new ObservableCollection <CTeamItem>(Teams.OrderBy(arg => arg.Name));

                CCompSpecificSets CompSettings;
                if (settings.dictCompSettings.TryGetValue(CompDesc.id_desc, out CompSettings))
                {
                    if (CompSettings.WomenInGroup != GlobalDefines.DEFAULT_XML_INT_VAL)
                    {
                        WomenInGroup = CompSettings.WomenInGroup;
                    }
                    else
                    {
                        WomenInGroup = settings.DefaultCompSettings.WomenInGroup;
                    }

                    if (CompSettings.MenInGroup != GlobalDefines.DEFAULT_XML_INT_VAL)
                    {
                        MenInGroup = CompSettings.MenInGroup;
                    }
                    else
                    {
                        MenInGroup = settings.DefaultCompSettings.MenInGroup;
                    }

                    // Удаляем команды, которых больше нет в соревновании и
                    // заполняем свойства, которые будут использованы для вывода команд на экран
                    if (CompGroups.Count > 0 && CompSettings.lstTeamsForTeamReport != null)
                    {
                        bool AppSettingsChanged = false;
                        for (int n = 0; n < CompSettings.lstTeamsForTeamReport.Count;)
                        {
                            if (CompSettings.lstTeamsForTeamReport[n].SubteamsIds != null)
                            {
                                CTeamForReportItem TeamForReport = new CTeamForReportItem(TeamForReportItem_CommandHandler)
                                {
                                    Name = CompSettings.lstTeamsForTeamReport[n].Name,
                                };

                                for (int m = 0; m < CompSettings.lstTeamsForTeamReport[n].SubteamsIds.Count;)
                                {
                                    long      TeamId   = CompSettings.lstTeamsForTeamReport[n].SubteamsIds[m];
                                    CTeamItem TeamItem = Teams.FirstOrDefault(arg => arg.id == TeamId);
                                    if (TeamItem == null)
                                    {   // Такой команды больше нет
                                        CompSettings.lstTeamsForTeamReport[n].SubteamsIds.RemoveAt(m);
                                        AppSettingsChanged = true;
                                    }
                                    else
                                    {
                                        TeamForReport.Subteams.Add(new CTeamItem(TeamId)
                                        {
                                            Name = TeamItem.Name.Trim()
                                        });
                                        Teams.Remove(TeamItem); // Команды в Teams и TeamsForReport повторяться не должны
                                        m++;
                                    }
                                }
                                if (CompSettings.lstTeamsForTeamReport[n].SubteamsIds.Count == 0)
                                {   // Команд больше не осталось
                                    CompSettings.lstTeamsForTeamReport.RemoveAt(n);
                                    AppSettingsChanged = true;
                                }
                                else
                                {
                                    TeamsForReport.Add(TeamForReport);
                                    n++;
                                }
                            }
                            else
                            {
                                CompSettings.lstTeamsForTeamReport.RemoveAt(n);
                                AppSettingsChanged = true;
                            }
                        }

                        if (AppSettingsChanged)
                        {
                            DBManagerApp.m_AppSettings.Write();
                        }
                    }
                }
                else
                {
                    WomenInGroup = settings.DefaultCompSettings.WomenInGroup;
                    MenInGroup   = settings.DefaultCompSettings.MenInGroup;
                }
            }
        }