2023-04-18 17:10:20 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2023-05-02 17:17:26 +00:00
|
|
|
|
using Valasztas2;
|
2023-04-18 17:10:20 +00:00
|
|
|
|
|
|
|
|
|
namespace ValasztasGUI
|
|
|
|
|
{
|
|
|
|
|
public partial class StatisztikaForm : Form
|
|
|
|
|
{
|
2023-05-02 17:17:26 +00:00
|
|
|
|
|
|
|
|
|
public List<Kepviselo> jeloltek;
|
|
|
|
|
public Dictionary<string, string> partok;
|
2023-04-18 17:10:20 +00:00
|
|
|
|
public StatisztikaForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
2023-05-02 17:17:26 +00:00
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int osszes = int.Parse(textBox1.Text);
|
|
|
|
|
textBox2.Text = jeloltek.Count.ToString();
|
|
|
|
|
// leadott szavazatok száma lambda kifejezéssel
|
|
|
|
|
double leadott = jeloltek.Sum(x => x.Szavazat);
|
|
|
|
|
// vagy nem lambda:
|
|
|
|
|
int leadott2 = 0;
|
|
|
|
|
foreach (var item in jeloltek)
|
|
|
|
|
{
|
|
|
|
|
leadott2 += item.Szavazat;
|
|
|
|
|
}
|
|
|
|
|
textBox3.Text = leadott.ToString();
|
|
|
|
|
double arany = leadott / osszes * 100;
|
|
|
|
|
textBox4.Text = arany.ToString("F2");
|
|
|
|
|
textBox4.Text = $"{arany:F2}";
|
|
|
|
|
|
|
|
|
|
//partok aranya
|
|
|
|
|
Dictionary<string,double> partok2 = new Dictionary<string, double>();
|
|
|
|
|
partok2.Add("ZEP",0);
|
|
|
|
|
partok2.Add("HEP",0);
|
|
|
|
|
partok2.Add("GYEP",0);
|
|
|
|
|
partok2.Add("TISZ",0);
|
|
|
|
|
partok2.Add("független",0);
|
|
|
|
|
foreach (var kj in jeloltek)
|
|
|
|
|
{
|
|
|
|
|
partok2[kj.Part] += kj.Szavazat;
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in partok2.Keys)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Label pc = new Label();
|
|
|
|
|
pc.Text = partok[item];
|
|
|
|
|
Label ac = new Label();
|
|
|
|
|
ac.Text = (partok2[item]/leadott*100).ToString("F2")+" %";
|
|
|
|
|
tableLayoutPanel1.Controls.Add(pc);
|
|
|
|
|
tableLayoutPanel1.Controls.Add(ac);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Hiba az összes jogosult megadásában!", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 17:10:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|