Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 penztar
- {
- public partial class Form1 : Form
- {
- public int teljesosszeg = 0;
- struct adat
- {
- public string nev;
- public int osszeg;
- public string ido;
- public int osszespenz;
- }
- List<adat> listacska = new List<adat>();
- public string eleres = Environment.CurrentDirectory + "\\mentes.txt";
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- radioButton1.Checked = true;
- if (!File.Exists(eleres))
- {
- File.CreateText("mentes.txt");
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- DateTime most = DateTime.Now;
- try
- {
- string nev = textBox1.Text;
- int osszeg = int.Parse(textBox2.Text);
- if (radioButton1.Checked)
- {
- teljesosszeg += osszeg;
- listBox1.Items.Add(nev + " " + osszeg + " " + most + " " + teljesosszeg);
- osszespenzlabel.Text = teljesosszeg.ToString();
- textBox1.Text = null;
- textBox2.Text = null;
- }
- else
- {
- teljesosszeg -= osszeg;
- if (teljesosszeg < 0)
- {
- MessageBox.Show("Nem lehet 0-nál kevesebb pénz a kasszában!");
- textBox1.Text = null;
- textBox2.Text = null;
- }
- else
- {
- listBox1.Items.Add(nev + " " + osszeg + " " + most + " " + teljesosszeg);
- osszespenzlabel.Text = teljesosszeg.ToString();
- textBox1.Text = null;
- textBox2.Text = null;
- }
- }
- }
- catch (FormatException)
- {
- MessageBox.Show("Csak számot és nevet adhat meg a megfelelő mezőkben!");
- }
- catch (OverflowException)
- {
- MessageBox.Show("Túl nagy számot adott meg!");
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- string listboxtartalom = "";
- foreach (string str in listBox1.Items)
- {
- listboxtartalom += str + "\n" + Environment.NewLine;
- }
- File.WriteAllText(eleres, listboxtartalom);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- StreamReader olvaso = new StreamReader(eleres);
- while(!olvaso.EndOfStream)
- {
- string[] egysor = olvaso.ReadLine().Split(Convert.ToChar(32));
- adat temp = new adat();
- temp.nev = egysor[0];
- temp.osszeg = Convert.ToInt16(egysor[1]);
- temp.ido = egysor[2];
- }
- }
- private void button4_Click(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement