private void btnMakeCoalition_Click(object sender, EventArgs e) { if (tbCoalitionName.Text != null && clbParties.CheckedItems.Count > 1) { List <ElectionResult> parties = new List <ElectionResult>(); foreach (object result in clbParties.CheckedItems) { ElectionResult res = (ElectionResult)result; parties.Add(res); } Coalition coalition = new Coalition(tbCoalitionName.Text, parties); coalition.aMayority(parties, election); sql.NewCoalition(coalition); MessageBox.Show("Coalitie " + coalition.Name + " is gevormd."); } }
private void clbParties_ItemCheck(object sender, ItemCheckEventArgs e) { Coalition coalition = new Coalition(); foreach (object result in clbParties.CheckedItems) { ElectionResult res = (ElectionResult)result; coalition.Parties.Add(res); } if (e.NewValue == CheckState.Checked) { ElectionResult result = (ElectionResult)clbParties.Items[e.Index]; coalition.Parties.Add(result); } if (coalition.aMayority(results, election) == true) { lblMayority.Text = "Deze coalitie heeft een meerderheid!"; } else { lblMayority.Text = "Deze coalitie heeft een minderheid!"; } }