Kész a feladat.
This commit is contained in:
parent
795acb3866
commit
869f992884
38
ValasztasGUI/Form1.Designer.cs
generated
38
ValasztasGUI/Form1.Designer.cs
generated
|
@ -34,6 +34,8 @@ namespace ValasztasGUI
|
||||||
this.megnyitásToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.megnyitásToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.kilépésToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.kilépésToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.műveletekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.műveletekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.statisztikaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.nyertesekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.súgóToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.súgóToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
@ -50,8 +52,7 @@ namespace ValasztasGUI
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.listBox2 = new System.Windows.Forms.ListBox();
|
this.listBox2 = new System.Windows.Forms.ListBox();
|
||||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.statisztikaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.névjegyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.nyertesekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
|
@ -100,8 +101,24 @@ namespace ValasztasGUI
|
||||||
this.műveletekToolStripMenuItem.Size = new System.Drawing.Size(74, 20);
|
this.műveletekToolStripMenuItem.Size = new System.Drawing.Size(74, 20);
|
||||||
this.műveletekToolStripMenuItem.Text = "Műveletek";
|
this.műveletekToolStripMenuItem.Text = "Műveletek";
|
||||||
//
|
//
|
||||||
|
// statisztikaToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.statisztikaToolStripMenuItem.Name = "statisztikaToolStripMenuItem";
|
||||||
|
this.statisztikaToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.statisztikaToolStripMenuItem.Text = "Statisztika";
|
||||||
|
this.statisztikaToolStripMenuItem.Click += new System.EventHandler(this.statisztikaToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// nyertesekToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.nyertesekToolStripMenuItem.Name = "nyertesekToolStripMenuItem";
|
||||||
|
this.nyertesekToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.nyertesekToolStripMenuItem.Text = "Nyertesek";
|
||||||
|
this.nyertesekToolStripMenuItem.Click += new System.EventHandler(this.nyertesekToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// súgóToolStripMenuItem
|
// súgóToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
this.súgóToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.névjegyToolStripMenuItem});
|
||||||
this.súgóToolStripMenuItem.Name = "súgóToolStripMenuItem";
|
this.súgóToolStripMenuItem.Name = "súgóToolStripMenuItem";
|
||||||
this.súgóToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
|
this.súgóToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
|
||||||
this.súgóToolStripMenuItem.Text = "Súgó";
|
this.súgóToolStripMenuItem.Text = "Súgó";
|
||||||
|
@ -238,18 +255,12 @@ namespace ValasztasGUI
|
||||||
//
|
//
|
||||||
this.openFileDialog1.FileName = "openFileDialog1";
|
this.openFileDialog1.FileName = "openFileDialog1";
|
||||||
//
|
//
|
||||||
// statisztikaToolStripMenuItem
|
// névjegyToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.statisztikaToolStripMenuItem.Name = "statisztikaToolStripMenuItem";
|
this.névjegyToolStripMenuItem.Name = "névjegyToolStripMenuItem";
|
||||||
this.statisztikaToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.névjegyToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.statisztikaToolStripMenuItem.Text = "Statisztika";
|
this.névjegyToolStripMenuItem.Text = "Névjegy";
|
||||||
this.statisztikaToolStripMenuItem.Click += new System.EventHandler(this.statisztikaToolStripMenuItem_Click);
|
this.névjegyToolStripMenuItem.Click += new System.EventHandler(this.névjegyToolStripMenuItem_Click);
|
||||||
//
|
|
||||||
// nyertesekToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.nyertesekToolStripMenuItem.Name = "nyertesekToolStripMenuItem";
|
|
||||||
this.nyertesekToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
|
||||||
this.nyertesekToolStripMenuItem.Text = "Nyertesek";
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
|
@ -300,6 +311,7 @@ namespace ValasztasGUI
|
||||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem statisztikaToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem statisztikaToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem nyertesekToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem nyertesekToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem névjegyToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -51,6 +52,7 @@ namespace ValasztasGUI
|
||||||
|
|
||||||
if(listBox1.SelectedIndex>=0)
|
if(listBox1.SelectedIndex>=0)
|
||||||
{
|
{
|
||||||
|
listBox2.Items.Clear();
|
||||||
Kepviselo kk = (listBox1.SelectedItem as Kepviselo);
|
Kepviselo kk = (listBox1.SelectedItem as Kepviselo);
|
||||||
nevmezo.Text = kk.TeljesNev;
|
nevmezo.Text = kk.TeljesNev;
|
||||||
keruletmezo.Text = kk.Kerulet.ToString();
|
keruletmezo.Text = kk.Kerulet.ToString();
|
||||||
|
@ -89,8 +91,36 @@ namespace ValasztasGUI
|
||||||
{
|
{
|
||||||
//a másik form megnyitása
|
//a másik form megnyitása
|
||||||
StatisztikaForm f2 = new StatisztikaForm();
|
StatisztikaForm f2 = new StatisztikaForm();
|
||||||
|
f2.jeloltek = jeloltek;
|
||||||
|
f2.partok = partok;
|
||||||
f2.ShowDialog();
|
f2.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void nyertesekToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(jeloltek!=null && jeloltek.Count>0) {
|
||||||
|
StreamWriter sw = new StreamWriter("nyertesek.txt");
|
||||||
|
for (int ker = 1; ker < 9; ker++)
|
||||||
|
{
|
||||||
|
Kepviselo nyero = null;
|
||||||
|
foreach (var item in jeloltek)
|
||||||
|
{
|
||||||
|
if(item.Kerulet == ker && (nyero==null || item.Szavazat>nyero.Szavazat))
|
||||||
|
{
|
||||||
|
nyero = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sw.WriteLine($"{nyero.Kerulet} {nyero.TeljesNev} {nyero.Part}");
|
||||||
|
}
|
||||||
|
sw.Close();
|
||||||
|
MessageBox.Show("A nyertesek létrehozva!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void névjegyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Helyhatósági v. elemző program", "Névjegy", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
ValasztasGUI/StatisztikaForm.Designer.cs
generated
20
ValasztasGUI/StatisztikaForm.Designer.cs
generated
|
@ -42,6 +42,7 @@ namespace ValasztasGUI
|
||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.label6 = new System.Windows.Forms.Label();
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -79,6 +80,7 @@ namespace ValasztasGUI
|
||||||
this.button1.TabIndex = 3;
|
this.button1.TabIndex = 3;
|
||||||
this.button1.Text = "Statisztika kitöltése";
|
this.button1.Text = "Statisztika kitöltése";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
//
|
//
|
||||||
// textBox2
|
// textBox2
|
||||||
//
|
//
|
||||||
|
@ -156,11 +158,28 @@ namespace ValasztasGUI
|
||||||
this.label6.TabIndex = 12;
|
this.label6.TabIndex = 12;
|
||||||
this.label6.Text = "Az egyes pártokra leadott szavazatok aránya:";
|
this.label6.Text = "Az egyes pártokra leadott szavazatok aránya:";
|
||||||
//
|
//
|
||||||
|
// tableLayoutPanel1
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel1.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
|
||||||
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(15, 230);
|
||||||
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
|
this.tableLayoutPanel1.RowCount = 5;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||||
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(399, 157);
|
||||||
|
this.tableLayoutPanel1.TabIndex = 13;
|
||||||
|
//
|
||||||
// StatisztikaForm
|
// StatisztikaForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(439, 450);
|
this.ClientSize = new System.Drawing.Size(439, 450);
|
||||||
|
this.Controls.Add(this.tableLayoutPanel1);
|
||||||
this.Controls.Add(this.label6);
|
this.Controls.Add(this.label6);
|
||||||
this.Controls.Add(this.button2);
|
this.Controls.Add(this.button2);
|
||||||
this.Controls.Add(this.label5);
|
this.Controls.Add(this.label5);
|
||||||
|
@ -197,5 +216,6 @@ namespace ValasztasGUI
|
||||||
private System.Windows.Forms.Label label5;
|
private System.Windows.Forms.Label label5;
|
||||||
private System.Windows.Forms.Button button2;
|
private System.Windows.Forms.Button button2;
|
||||||
private System.Windows.Forms.Label label6;
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,11 +7,15 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Valasztas2;
|
||||||
|
|
||||||
namespace ValasztasGUI
|
namespace ValasztasGUI
|
||||||
{
|
{
|
||||||
public partial class StatisztikaForm : Form
|
public partial class StatisztikaForm : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public List<Kepviselo> jeloltek;
|
||||||
|
public Dictionary<string, string> partok;
|
||||||
public StatisztikaForm()
|
public StatisztikaForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -21,5 +25,53 @@ namespace ValasztasGUI
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user