67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows;
|
|||
|
using System.Windows.Controls;
|
|||
|
using System.Windows.Data;
|
|||
|
using System.Windows.Documents;
|
|||
|
using System.Windows.Input;
|
|||
|
using System.Windows.Media;
|
|||
|
using System.Windows.Media.Imaging;
|
|||
|
using System.Windows.Shapes;
|
|||
|
|
|||
|
namespace ValasztasGUI.View
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Interaction logic for Statisztika.xaml
|
|||
|
/// </summary>
|
|||
|
public partial class Statisztika : Window
|
|||
|
{
|
|||
|
public Statisztika()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
|
|||
|
private void szavazasraJogosultakSzamaButton_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
bool szam = Int32.TryParse(szavazasraJogosultakSzamaTextBox.Text, out int result );
|
|||
|
|
|||
|
if (!szam)
|
|||
|
{
|
|||
|
MessageBox.Show("Hiba az összes jogosult megadásában!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
kepviselokSzamaTextBox.Text = $"{Eredmeny.kepviselok.Count}";
|
|||
|
|
|||
|
int totalszavazatok = Eredmeny.kepviselok.Sum(x => x.Szavazat);
|
|||
|
szavazottakTextBox.Text = $"{totalszavazatok}";
|
|||
|
|
|||
|
double szazalek = ((double)totalszavazatok / (double)result) * 100;
|
|||
|
szazalekTextBox.Text = szazalek.ToString("0.##");
|
|||
|
|
|||
|
|
|||
|
var partokTeljesitmenye = Eredmeny.kepviselok.GroupBy(x => x.Part).Select(g => new
|
|||
|
{
|
|||
|
Part = g.Key,
|
|||
|
Szazalek = ((double)g.Count() / (double)totalszavazatok) * 10000
|
|||
|
})
|
|||
|
.OrderByDescending(x => x.Szazalek)
|
|||
|
.Select(x => (x.Part, x.Szazalek))
|
|||
|
.ToList();
|
|||
|
|
|||
|
foreach (var item in partokTeljesitmenye)
|
|||
|
{
|
|||
|
szavazatiaranyokListBox.Items.Add($"{(item.Part == "-" ? "független" : item.Part)} {item.Szazalek.ToString("0.##")}%");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|