Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            FilePath = new DBProcessing(_myConnectionString);
            var teams   = FilePath.GetTeams();
            var players = FilePath.GetBasketballPlayers();
            var image   = new MenuImagesProcessing();

            foreach (var item in teams)
            {
                item.BasketballPlayers = players;
            }
            var basketballPlayer = new BasketballPlayers();
            var team             = new Teams();

            foreach (var item in players)
            {
                basketballPlayer.CheckPlayerPicture(item);
            }
            foreach (var item in teams)
            {
                team.CheckTeamPicture(item);
            }
            foreach (var item in teams)
            {
                item.BasketballPlayers = basketballPlayer.RelatePlayerToATeam(item, players);;
            }
            _teamsList   = teams;
            _teamsToSort = teams;
            connection   = new MySqlConnection(_myConnectionString);
            _positions   = FilePath.GetPositions();

            //_menuImages = image.GetImagesFromFile();
        }
Пример #2
0
        private void btnConfirmAddingPlayer_Click(object sender, RoutedEventArgs e)
        {
            ClearTeamsInterface();

            var               selectedTeam     = cbToEditOrAddTeams.SelectedItem;
            var               selectedPosition = cbToEditOrAddPositions.SelectedItem;
            Positions         position         = selectedPosition as Positions;
            Teams             team             = selectedTeam as Teams;
            BasketballPlayers player1          = new BasketballPlayers();

            GetPlayerFromForm(player1, team, position);

            var errMsg = CombinedPlayerCheck(player1);

            player1.CheckPlayerPicture(player1);

            if (!string.IsNullOrEmpty(errMsg))
            {
                ToLog(errMsg, MessageBoxImage.Error);
                UpdateInterface();
                return;
            }

            FilePath.Append(player1);

            UpdateInterface();
            ToLog($"{player1.Name} was successfully added", MessageBoxImage.Information);

            ClearPlayersInterface();
        }
Пример #3
0
        private void btnConfirmEditingPlayer_Click(object sender, RoutedEventArgs e)
        {
            var               selectedTeam                 = cbToEditOrAddTeams.SelectedItem;
            var               selectedPosition             = cbToEditOrAddPositions.SelectedItem;
            Positions         position                     = selectedPosition as Positions;
            Teams             team                         = selectedTeam as Teams;
            var               player                       = lvPlayers.SelectedValue;
            BasketballPlayers player1                      = player as BasketballPlayers;
            BindingList <BasketballPlayers> currentPlayers = FilePath.GetBasketballPlayers();
            string message = player1.Name;

            GetPlayerFromForm(player1, team, position);


            var errMsg = CombinedPlayerCheck(player1);

            if (!string.IsNullOrEmpty(errMsg))
            {
                ToLog(errMsg, MessageBoxImage.Error);
                UpdateInterface();
                return;
            }
            player1.CheckPlayerPicture(player1);
            foreach (var item in currentPlayers)
            {
                if (player1.ID == item.ID)
                {
                    currentPlayers.Remove(item);
                    currentPlayers.Add(player1);
                    break;
                }
            }

            FilePath.SaveData(currentPlayers);

            UpdateInterface();
            ToLog($"{message} was successfully edited", MessageBoxImage.Information);

            ClearPlayersInterface();
        }