private void buttonDelete_Click(object sender, EventArgs e)
        {
            DialogResult confirm = MessageBox.Show("Matchup akan didelete, Apakah anda yakin?", "Confirm", MessageBoxButtons.YesNo);

            if (confirm == System.Windows.Forms.DialogResult.Yes)
            {
                int    matchupSelectedIndex = dataGridViewMatchup.CurrentCell.RowIndex;
                string selectedMatchupId    = dataGridViewMatchup.Rows[matchupSelectedIndex].Cells[0].Value.ToString();

                selectedMatchup = Matchups.SelectMatchup(selectedMatchupId);

                List <MatchupEntries> pair = Matchups.GetEntries(selectedMatchup);
                selectedMatchupEntry1 = pair[0];
                selectedMatchupEntry2 = pair[1];

                MatchupEntries.Delete(selectedMatchup, selectedMatchupEntry1.Team);
                MatchupEntries.Delete(selectedMatchup, selectedMatchupEntry2.Team);

                Matchups.DeleteMatchup(selectedMatchup);

                MessageBox.Show("Delete successful.");
            }
            else
            {
                MessageBox.Show("Delete matchup canceled.");
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string   matchupId    = textBoxId.Text;
                int      matchupRound = int.Parse(textBoxRound.Text);
                DateTime matchupDate  = dateTimePickerMatchup.Value;

                Matchups mat = new Matchups(matchupId, matchupRound, matchupDate);
                Matchups.AddMatchup(mat);

                Teams team1 = (Teams)comboBoxTeam1.SelectedItem;
                Teams team2 = (Teams)comboBoxTeam2.SelectedItem;


                double team1AddScore = double.Parse(textBoxScore1.Text);
                double team2AddScore = double.Parse(textBoxScore2.Text);

                MatchupEntries.Add(mat, team1, team1AddScore);
                MatchupEntries.Add(mat, team2, team2AddScore);

                team1.AddScore(team1AddScore);
                team2.AddScore(team2AddScore);

                MessageBox.Show("Matchup has been Saved", "Information");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Matchups cannot be saved. Error Message: " + ex.Message, "Error");
            }
        }
        public void FormMatch_Load(object sender, EventArgs e)
        {
            //Menampilkan Data dari database tabel matchup
            FormatDataGridMatchup();
            matchupList = Matchups.ReadData(FormMenu.selectedTournament);
            ShowDataGridMatchup();

            //Menampilkan Data dari database tabel matchupEntries
            FormatDataGridMatchupEntries();
            entryList = MatchupEntries.ReadData(FormMenu.selectedTournament);
            ShowDataGridMatchupEntries();
        }
        private void buttonEditMatchup_Click(object sender, EventArgs e)
        {
            int    matchupSelectedIndex = dataGridViewMatchup.CurrentCell.RowIndex;
            string selectedMatchupId    = dataGridViewMatchup.Rows[matchupSelectedIndex].Cells[0].Value.ToString();

            selectedMatchup = Matchups.SelectMatchup(selectedMatchupId);

            List <MatchupEntries> pair = Matchups.GetEntries(selectedMatchup);

            selectedMatchupEntry1 = pair[0];
            selectedMatchupEntry2 = pair[1];

            FormEditMatchup formEditMatchup = new FormEditMatchup();

            formEditMatchup.Owner = this;
            formEditMatchup.ShowDialog();
        }
예제 #5
0
        private void ButtonEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string   matchupId    = textBoxId.Text;
                int      matchupRound = int.Parse(textBoxRound.Text);
                DateTime matchupDate  = dateTimePickerMatchup.Value;

                Matchups matchup = new Matchups(matchupId, matchupRound, matchupDate);
                Matchups.EditMatchup(matchup);

                Teams team1 = (Teams)comboBoxTeam1.SelectedItem;
                Teams team2 = (Teams)comboBoxTeam2.SelectedItem;

                double team1NewEntryScore = double.Parse(textBoxScore1.Text);
                double team2NewEntryScore = double.Parse(textBoxScore2.Text);

                MatchupEntries.Edit(matchup, team1, team1NewEntryScore);
                MatchupEntries.Edit(matchup, team2, team2NewEntryScore);

                double oldTeam1EntryScore = FormMatch.selectedMatchupEntry1.Score;
                double oldTeam2EntryScore = FormMatch.selectedMatchupEntry2.Score;

                team1.SubstractScore(oldTeam1EntryScore);
                team2.SubstractScore(oldTeam2EntryScore);

                team1.AddScore(team1NewEntryScore);
                team2.AddScore(team2NewEntryScore);

                MessageBox.Show("Matchup has been Saved", "Information");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fail to edit matchup, " + ex.Message, "Error");
            }
        }