2023-04-04 17:09:00 +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;
|
|
|
|
|
using Valasztas2;
|
|
|
|
|
|
|
|
|
|
namespace ValasztasGUI
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
2023-04-18 17:10:20 +00:00
|
|
|
|
|
|
|
|
|
Dictionary<string, string> partok;
|
|
|
|
|
List<Kepviselo> jeloltek;
|
2023-04-04 17:09:00 +00:00
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2023-04-18 17:10:20 +00:00
|
|
|
|
partok = new Dictionary<string, string>();
|
|
|
|
|
partok.Add("ZEP", "Zöldségevők pártja");
|
|
|
|
|
partok.Add("HEP", "Húsevők pártja");
|
|
|
|
|
partok.Add("GYEP", "Gyümölcsevők pártja");
|
|
|
|
|
partok.Add("TISZ", "Tejivók szövetsége");
|
|
|
|
|
partok.Add("független", "független");
|
2023-04-04 17:09:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void megnyitásToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (openFileDialog1.ShowDialog()==DialogResult.OK)
|
|
|
|
|
{
|
2023-04-18 17:10:20 +00:00
|
|
|
|
jeloltek = Kepviselo.LoadFromTxt(openFileDialog1.FileName);
|
2023-04-04 17:09:00 +00:00
|
|
|
|
listBox1.Items.AddRange(jeloltek.ToArray());
|
|
|
|
|
// vagy listBox1.DataSource = jeloltek;
|
|
|
|
|
listBox1.DisplayMember = "TeljesNev";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void kilépésToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//this.Close();
|
|
|
|
|
Application.Exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-04-18 17:10:20 +00:00
|
|
|
|
|
2023-04-04 17:09:00 +00:00
|
|
|
|
if(listBox1.SelectedIndex>=0)
|
|
|
|
|
{
|
|
|
|
|
Kepviselo kk = (listBox1.SelectedItem as Kepviselo);
|
|
|
|
|
nevmezo.Text = kk.TeljesNev;
|
|
|
|
|
keruletmezo.Text = kk.Kerulet.ToString();
|
|
|
|
|
partmezo.Text = partok[kk.Part];
|
|
|
|
|
szavazatmezo.Text = kk.Szavazat.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 17:10:20 +00:00
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (listBox1.SelectedIndex<0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Nincs kiválasztott képviselő!", "Hiba!",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
Kepviselo kk = (listBox1.SelectedItem as Kepviselo);
|
|
|
|
|
//listBox2.DisplayMember = "Teljesnev";
|
|
|
|
|
foreach (var item in jeloltek)
|
|
|
|
|
{
|
|
|
|
|
if(item.Kerulet == kk.Kerulet && item!=kk)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
listBox2.Items.Add($"{item.TeljesNev} ({item.Szavazat} szavazat)");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void statisztikaToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(jeloltek==null || jeloltek.Count==0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Nincsenek képviselői adatok!", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
//a másik form megnyitása
|
|
|
|
|
StatisztikaForm f2 = new StatisztikaForm();
|
|
|
|
|
f2.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-04 17:09:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|