Exemplo n.º 1
0
        private void Update_Click(object sender, EventArgs e)
        {
            int votes;

            if (Update.Text == "Pas aan")
            {
                if (int.TryParse(tbVotes.Text, out votes) && cbParty.SelectedItem != null)
                {
                    election.ChangeResults(cbParty.SelectedItem.ToString(), votes, sql);
                    MessageBox.Show("De uitslag is succelvol aangepast.");
                    this.Close();
                }
            }
            else if (Update.Text == "Nieuw resultaat")
            {
                DateTime temp;
                if (DateTime.TryParse(tbDateTime.Text, out temp) && int.TryParse(tbVotes.Text, out votes) && cbParty.SelectedItem != null)
                {
                    election.Name = cbElections.Text;
                    election.AddParty((Party)cbParty.SelectedItem);
                    ElectionResult result = new ElectionResult();
                    election.AddResult(result);
                    result.CalculateSeats(Convert.ToInt32(tbVotes.Text));
                    sql.NewResult(result, election.Name);
                    MessageBox.Show("De uitslag is succelvol opgeslagen.");
                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
 private void btnPartyOverview_Click(object sender, EventArgs e)
 {
     election       = (Election)cbElection.SelectedItem;
     gbEdit.Visible = true;
     results        = sql.LoadResultsForElection(election);
     clbParties.Items.Clear();
     foreach (ElectionResult result in results)
     {
         election.AddResult(result);
         election.AddParty(result.Party);
         clbParties.Items.Add(result, false);
     }
 }