Esempio n. 1
0
        private void UpdateTeamStats(BasicTeam team)
        {
            //if the app shows a bug or a delay -> reset the sequence to 0, transcate matches table, AND COMMIT
            string query = string.Format("UPDATE team t SET t.points = {0}, t.win = {1}, t.draw = {2}, t.loss = {3} WHERE country = '{4}'",
                                         team.points,
                                         team.win,
                                         team.draw,
                                         team.loss,
                                         team.Name
                                         );

            _myConnection.Open();
            OracleCommand cmd = new OracleCommand(query);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = _myConnection;
            int rowsAffected = cmd.ExecuteNonQuery();

            _myConnection.Close();

            if (rowsAffected != 1)
            {
                throw new Exception("DataBaseConnection::UpdateTeamStats() -> rowsAffected != 1");
            }
        }
Esempio n. 2
0
        public static BasicTeam DeepCopyTeam(BasicTeam basicTeam)
        {
            BasicTeam teamToReturn = new BasicTeam(
                DeepCopy(basicTeam.Flag),
                string.Copy(basicTeam.Name),
                string.Copy(basicTeam.Continent),
                string.Copy(basicTeam.Group)
                );

            return(teamToReturn);
        }
Esempio n. 3
0
        public void SetUpScheduleForGroup(Group group)
        {
            List <BasicTeam> teamsList = BasicTeam.DeepCopyTeamsList(group.GetGroupTeams());

            _matchesList.Add(new Match((BasicTeam)teamsList[0], (BasicTeam)teamsList[1], _day1));
            _matchesList.Add(new Match((BasicTeam)teamsList[0], (BasicTeam)teamsList[2], _day1));

            _matchesList.Add(new Match((BasicTeam)teamsList[0], (BasicTeam)teamsList[3], _day2));
            _matchesList.Add(new Match((BasicTeam)teamsList[1], (BasicTeam)teamsList[2], _day2));

            _matchesList.Add(new Match((BasicTeam)teamsList[1], (BasicTeam)teamsList[3], _day3));
            _matchesList.Add(new Match((BasicTeam)teamsList[2], (BasicTeam)teamsList[3], _day3));
        }
Esempio n. 4
0
        public Match(BasicTeam team1, BasicTeam team2, DateTime matchDate)
        {
            Team1              = BasicTeam.DeepCopyTeam(team1);
            Team2              = BasicTeam.DeepCopyTeam(team2);
            score1             = new TextBox();
            score2             = new TextBox();
            MatchDate          = matchDate;
            DateLabel.AutoSize = true;
            DateLabel.Text     = matchDate.ToLongDateString();

            score1.Text = "";
            score2.Text = "";

            score1.Width = score2.Width = 20;
            score1.Font  = score2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
Esempio n. 5
0
 //pass null value to arg (bool? isTeam1) in case of a draw
 private void CalculateTotalForTeam(BasicTeam team, int pos, bool?isTeam1)
 {
     if (isTeam1 == true)
     {
         team.points += _matchesList[pos].Team1.points;
         team.win    += _matchesList[pos].Team1.win;
         team.draw   += _matchesList[pos].Team1.draw;
         team.loss   += _matchesList[pos].Team1.loss;
     }
     else if (isTeam1 == false)
     {
         team.points += _matchesList[pos].Team2.points;
         team.win    += _matchesList[pos].Team2.win;
         team.draw   += _matchesList[pos].Team2.draw;
         team.loss   += _matchesList[pos].Team2.loss;
     }
 }
Esempio n. 6
0
        private void ValidateClick(object sender, EventArgs e)
        {
            ValidationButton.Enabled = false;
            List <BasicTeam> finalTeams = new List <BasicTeam>(capacity: 4);

            foreach (var match in _matchesList)
            {
                match.MakeFieldsReadOnly();
                match.SetResultToTeam();
            }

            BasicTeam t1 = new BasicTeam(null, _matchesList[0].Team1.Name, _matchesList[0].Team1.Continent, null);
            BasicTeam t2 = new BasicTeam(null, _matchesList[0].Team2.Name, _matchesList[0].Team2.Continent, null);
            BasicTeam t3 = new BasicTeam(null, _matchesList[1].Team2.Name, _matchesList[1].Team2.Continent, null);
            BasicTeam t4 = new BasicTeam(null, _matchesList[2].Team2.Name, _matchesList[2].Team2.Continent, null);

            for (int i = 0; i < 3; i++)
            {
                CalculateTotalForTeam(t1, i, true);
            }

            CalculateTotalForTeam(t2, 0, false);
            CalculateTotalForTeam(t2, 3, true);
            CalculateTotalForTeam(t2, 4, true);

            CalculateTotalForTeam(t3, 1, false);
            CalculateTotalForTeam(t3, 3, false);
            CalculateTotalForTeam(t3, 5, true);

            CalculateTotalForTeam(t4, 2, false);
            CalculateTotalForTeam(t4, 4, false);
            CalculateTotalForTeam(t4, 5, false);

            finalTeams.Add(t1); finalTeams.Add(t2);
            finalTeams.Add(t3); finalTeams.Add(t4);

            Engine32Teams.UpdateMatchResults(_matchesList);

            Engine32Teams.UpdateTeamsStats(finalTeams);
        }