237 lines
5.7 KiB
C#
237 lines
5.7 KiB
C#
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 System.IO;
|
|
|
|
namespace FizetesGUI
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
DataRead();
|
|
Feladat3();
|
|
Feladat4();
|
|
Feladat7();
|
|
}
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
public void Feladat3()
|
|
{
|
|
this.dolgozo_count.Text += $"{Data.munkasok.Count}";
|
|
}
|
|
|
|
public void Feladat4()
|
|
{
|
|
int atlagber = AtlagBer();
|
|
string text = $"Bérek átlaga: {atlagber} ezer Forint";
|
|
this.atlagber.Text = text;
|
|
}
|
|
|
|
public static int AtlagBer()
|
|
{
|
|
int dolgozoknum = Data.munkasok.Count;
|
|
int dolgozokberSZUM = DolgozokBerSZUM();
|
|
|
|
|
|
return (dolgozokberSZUM / dolgozoknum) / 1000;
|
|
}
|
|
|
|
public static int DolgozokBerSZUM()
|
|
{
|
|
int szum = 0;
|
|
foreach (var item in Data.munkasok)
|
|
{
|
|
szum += item.Ber;
|
|
}
|
|
return szum;
|
|
}
|
|
|
|
public void Feladat6()
|
|
{
|
|
string reszleg = this.reszleg.Text;
|
|
int legjobbankereso_index = LegjobbanKereso_index(reszleg);
|
|
|
|
string message;
|
|
if (legjobbankereso_index == -1)
|
|
{
|
|
message = "A megadott részleg nem létezik a cégnél!";
|
|
}
|
|
else
|
|
{
|
|
message = $"Név: {Data.munkasok[legjobbankereso_index].Nev}\n";
|
|
message += $"Nem: {Data.munkasok[legjobbankereso_index].Nem}\n";
|
|
message += $"Belépés: {Data.munkasok[legjobbankereso_index].Belepes}\n";
|
|
message += $"Bér: {Data.munkasok[legjobbankereso_index].Ber}";
|
|
}
|
|
|
|
label2.Text = message;
|
|
}
|
|
|
|
public int LegjobbanKereso_index(string reszleg)
|
|
{
|
|
int legnagyobbBer = 0;
|
|
int legnagyobb_index = -1;
|
|
for (int i = 0; i < Data.munkasok.Count; i++)
|
|
{
|
|
if (Data.munkasok[i].Ber > legnagyobbBer && Data.munkasok[i].Reszleg == reszleg)
|
|
{
|
|
legnagyobbBer = Data.munkasok[i].Ber;
|
|
legnagyobb_index = i;
|
|
}
|
|
}
|
|
|
|
return legnagyobb_index;
|
|
}
|
|
|
|
public void Feladat7()
|
|
{
|
|
List<string> reszlegek = new List<string>();
|
|
|
|
foreach (var item in Data.munkasok)
|
|
{
|
|
if (!reszlegek.Contains(item.Reszleg))
|
|
{
|
|
reszlegek.Add(item.Reszleg);
|
|
}
|
|
}
|
|
|
|
int[] reszleg_db = new int[reszlegek.Count];
|
|
|
|
for (int i = 0; i < reszlegek.Count; i++)
|
|
{
|
|
for (int j = 0; j < Data.munkasok.Count; j++)
|
|
{
|
|
if (reszlegek[i] == Data.munkasok[j].Reszleg)
|
|
{
|
|
reszleg_db[i]++;
|
|
}
|
|
}
|
|
}
|
|
|
|
//TODO
|
|
for (int i = 0; i < reszlegek.Count; i++)
|
|
{
|
|
listBox2.Text = $"{reszlegek[i]} - {reszleg_db[i]} Fő";
|
|
}
|
|
}
|
|
|
|
public void DataRead()
|
|
{
|
|
string path = @"C:\Users\szabomarton\Desktop\C#\ProgaOra\20240905\berek2020.txt";
|
|
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
|
StreamReader streamReader = new StreamReader(fileStream);
|
|
|
|
string line = streamReader.ReadLine();
|
|
line = streamReader.ReadLine();
|
|
|
|
while (line != null)
|
|
{
|
|
string[] datas = line.Split(';');
|
|
string nev = datas[0];
|
|
string nem = datas[1];
|
|
string reszleg = datas[2];
|
|
int belepes = Convert.ToInt32(datas[3]);
|
|
int ber = Convert.ToInt32(datas[4]);
|
|
|
|
Munkas munkas = new Munkas(nev, nem, reszleg, belepes, ber);
|
|
Data.munkasok.Add(munkas);
|
|
|
|
line = streamReader.ReadLine();
|
|
}
|
|
|
|
streamReader.Close();
|
|
fileStream.Close();
|
|
}
|
|
|
|
//label2 = feladat 6 text
|
|
private void label2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void atlagber_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void legnagyobbBer_Click(object sender, EventArgs e)
|
|
{
|
|
Feladat6();
|
|
}
|
|
}
|
|
|
|
public static class Data
|
|
{
|
|
public static List<Munkas> munkasok = new List<Munkas>();
|
|
}
|
|
public class Munkas
|
|
{
|
|
public string Nev { get; private set; }
|
|
public string Nem { get; private set; }
|
|
public string Reszleg { get; private set; }
|
|
public int Belepes { get; private set; }
|
|
public int Ber { get; private set; }
|
|
|
|
public Munkas(string nev, string nem, string reszleg, int belepes, int ber)
|
|
{
|
|
Nev = nev;
|
|
Nem = nem;
|
|
Reszleg = reszleg;
|
|
Belepes = belepes;
|
|
Ber = ber;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
namespace Fizetes
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
|
|
|
|
|
|
Feladat6();
|
|
Feladat7();
|
|
|
|
Console.ReadLine();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
*/ |