コード例 #1
0
        private async void BtnSaveDetail_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                if (NumberPicker.Value < 0 || NumberPicker.Value > 95)
                {
                    MessageBox.Show("Minutes can't be under 0 or higher than 95 minutes.", "Error");
                    return;
                }
                var matchDetails = await _aPIServiceMatches.GetById <List <MatchDetails> >(Id, "MatchDetail");

                if (matchDetails.Count != 0)
                {
                    var lastRecord = matchDetails.LastOrDefault();
                    if (lastRecord.Minute > NumberPicker.Value)
                    {
                        MessageBox.Show("Last added detail have lower minute.", "Error");
                        return;
                    }
                }

                await _aPIServiceMatches.Insert <MatchDetails>(new MatchDetails
                {
                    ClubId     = int.Parse(CmbClubs.SelectedValue.ToString()),
                    MatchId    = Id,
                    Minute     = int.Parse(NumberPicker.Value.ToString()),
                    PlayerId   = int.Parse(CmbPlayers.SelectedValue.ToString()),
                    ActionType = int.Parse(CmbEvent.SelectedIndex.ToString()) - 1
                }, "NewDetailMatch");

                FrmMatchDetail frm = new FrmMatchDetail(Id);
                frm.Show();
                Close();
            }
        }
コード例 #2
0
        private void DgvMatches_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var id = DgvMatches.SelectedRows[0].Cells[0].Value;

            FrmMatchDetail frm = new FrmMatchDetail(int.Parse(id.ToString()));

            frm.Show();
        }
コード例 #3
0
        private async void BtnSimulate_Click(object sender, EventArgs e)
        {
            //random number of events
            try
            {
                Random random = new Random();
                int    num    = random.Next(1, 10);

                var homePlayers = await _aPIServiceContracts.GetById <List <Contracts> >(HomeClubId, "ClubContracts");

                var awayPlayers = await _aPIServiceContracts.GetById <List <Contracts> >(AwayClubId, "ClubContracts");

                for (int i = 1; i <= num; i++)
                {
                    var matchDetail = new MatchDetails
                    {
                        ActionType = random.Next(0, 4),
                        MatchId    = Id,
                        Minute     = random.Next(1, 95)
                    };
                    if (i % 2 == 0)
                    {
                        matchDetail.ClubId = HomeClubId;
                        var index = random.Next(homePlayers.Count());
                        matchDetail.PlayerId = homePlayers[index].PlayerId;
                    }
                    else
                    {
                        matchDetail.ClubId = AwayClubId;
                        var index = random.Next(awayPlayers.Count());
                        matchDetail.PlayerId = awayPlayers[index].PlayerId;
                    }
                    await _aPIServiceMatches.Insert <MatchDetails>(matchDetail, "NewDetailMatch");
                }
                BtnMatchFinish.Visible   = false;
                BtnNewEventMatch.Visible = false;
                BtnSimulate.Visible      = false;

                var match = await _aPIServiceMatches.GetById <Matches>(Id);

                match.IsFinished = true;
                var updatedMatch = await _aPIServiceMatches.Update <Matches>(match, match.Id.ToString());

                UpdatePoints(updatedMatch);

                MessageBox.Show("Match simulated", "Information");
                FrmMatchDetail frm = new FrmMatchDetail(Id);
                frm.Show();
                Close();
            }
            catch (Exception)
            {
                MessageBox.Show("There was an error while simulating match.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;

                throw;
            }
        }
コード例 #4
0
        private void DgvMatches_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var id = DgvMatches.SelectedRows[0].Cells[0].Value;

            if ((int)id == 0)
            {
                MessageBox.Show("You need to select a match.", "Error", MessageBoxButtons.OK);
                return;
            }

            FrmMatchDetail frmClubsList = new FrmMatchDetail(int.Parse(id.ToString()));

            frmClubsList.Show();
        }